PHPackages                             tozny/e3db - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. tozny/e3db

ActiveLibrary[Security](/categories/security)

tozny/e3db
==========

PHP client library for Tozny's End-to-End Encrypted Database.

1.2.0(7y ago)52072proprietaryPHPPHP &gt;=7.0CI failing

Since Jul 26Pushed 6y ago8 watchersCompare

[ Source](https://github.com/tozny/e3db-php)[ Packagist](https://packagist.org/packages/tozny/e3db)[ RSS](/packages/tozny-e3db/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

[![PHP 7.0+](https://camo.githubusercontent.com/1da9234d3e8591214847ecd710a92d09c9197f781991c1a2acfd4ab1fbdafeca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d372e302532422d677265656e2e737667)](https://camo.githubusercontent.com/1da9234d3e8591214847ecd710a92d09c9197f781991c1a2acfd4ab1fbdafeca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d372e302532422d677265656e2e737667) [![Build Status](https://camo.githubusercontent.com/9320f60e00ef1f2108917bf7945c3bf4384d9ad33684e15cd8002bbd680fed93/68747470733a2f2f7472617669732d63692e6f72672f746f7a6e792f653364622d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/tozny/e3db-php) [![Coverage Status](https://camo.githubusercontent.com/2f3432e231a96f8caaf211c898608c458bb64ac36a66ccc474f5dc3e2e155a7f/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f746f7a6e792f653364622d7068702f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/tozny/e3db-php) [![Packagist](https://camo.githubusercontent.com/e25d50f9695a6dc0441ed2a4bd1a4529f70fb024349df4f689c0d2d21f511958/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f7a6e792f653364622e737667)](https://packagist.org/packages/tozny/e3db)

Introduction
============

[](#introduction)

TozStore (formerly E3DB) is a storage platform with powerful sharing and consent management features. [Read more on our web site.](https://tozny.com/tozstore/)

TozStore provides a familiar JSON-based NoSQL-style API for reading, writing, and querying data stored securely in the cloud.

Installation
============

[](#installation)

Composer
--------

[](#composer)

To install with composer add the following to your `composer.json` file:

```
"require": {
    "tozny/e3db": "1.2.0"
}

```

Then run `php composer.phar install`

Registering a client
--------------------

[](#registering-a-client)

Register an account with [Tozny](https://dashboard.tozny.com/register) to get started. From the Admin Console you can create clients directly (and grab their credentials from the console) or create registration tokens to dynamically create clients with `Tozny\E3DB\Client::register()`. Clients registered from within the console will automatically back their credentials up to your account. Clients created dynamically via the SDK can *optionally* back their credentials up to your account.

For a more complete walkthrough, see [`/examples/registration.php`](https://github.com/tozny/e3db-php/blob/master/examples/registration.php).

### Without Credential Backup

[](#without-credential-backup)

```
$token = '...';
$client_name = '...';

list($public_key, $private_key) = \Tozny\E3DB\Client::generate_keypair();
$client_info = \Tozny\E3DB\Client::register($token, $client_name, $public_key);
```

The object returned from the server contains the client's UUID, API key, and API secret (as well as echos back the public key passed during registration). It's your responsibility to store this information locally as it *will not be recoverable* without credential backup.

### With Credential Backup

[](#with-credential-backup)

```
$token = '...';
$client_name = '...';

list($public_key, $private_key) = \Tozny\E3DB\Client::generate_keypair();
$client_info = \Tozny\E3DB\Client::register($token, $client_name, $public_key, $private_key, true);
```

The private key must be passed to the registration handler when backing up credentials as it is used to cryptographically sign the encrypted backup file stored on the server. The private key never leaves the system, and the stored credentials will only be accessible to the newly-registered client itself or the account with which it is registered.

Loading configuration and creating a client
-------------------------------------------

[](#loading-configuration-and-creating-a-client)

Configuration is managed at runtime by instantiating a `Tozny\E3DB\Config` object with your client's credentials.

```
/**
 * Assuming your credentials are stored as defined constants in the
 * application, pass them each into the configuration constructor as
 * follows:
 */
$config = new \Tozny\E3DB\Config(
  CLIENT_ID,
  API_KEY_ID,
  API_SECRET,
  PUBLIC_KEY,
  PRIVATE_KEY,
  API_URL
);

/**
 * Pass the configuration to the default coonection handler, which
 * uses Guzzle for requests. If you need a different library for
 * requests, subclass `\Tozny\E3DB\Connection` and pass an instance
 * of your custom implementation to the client instead.
 */
$connection = new \Tozny\E3DB\Connection\GuzzleConnection($config);

/**
 * Pass both the configuration and connection handler when building
 * a new client instance.
 */
$client = new \Tozny\E3DB\Client($config, $connection);
```

Usage
=====

[](#usage)

Writing a record
----------------

[](#writing-a-record)

To write new records to the database, call the `Tozny\E3DB\Client::write` method with a string describing the type of data to be written, along with an associative array containing the fields of the record. `Tozny\E3DB\Client::write` returns the newly created record.

```
$record = $client->write('contact', [
  'first_name' => 'Jon',
  'last_name'  => 'Snow',
  'phone'      => '555-555-1212',
]);

echo sprintf("Wrote record %s\n", $record->meta->record_id);
```

Querying records
----------------

[](#querying-records)

E3DB supports many options for querying records based on the fields stored in record metadata. Refer to the API documentation for the complete set of options that can be passed to `Tozny\E3DB\Client::query`.

For example, to list all records of type `contact` and print a simple report containing names and phone numbers:

```
$data = true;
$raw = false;
$writer = null;
$record = null;
$type = 'contact';

$records = $client->query($data, $raw, $writer, $record, $type);
foreach($records as $record) {
  $fullname = $record->data['first_name'] . ' ' . $record->data['last_name'];
  echo sprintf("%-40s %s\n", $fullname, $record->data['phone']);
}
```

In this example, the `Tozny\E3DB\Client::query` method returns an iterator that contains each record that matches the query.

More examples
-------------

[](#more-examples)

See [the simple example code](https://github.com/tozny/e3db-php/blob/master/examples/simple.php) for runnable detailed examples.

Development
===========

[](#development)

Before running tests, create a registration token through your [Tozny account](https://dashboard.tozny.com/register).

Store the registration token in a `.env` file at the project root (see `.env.example` for the example file layout). The integration tests will use this token to dynamically create test clients.

After checking out the repo, install dependencies using `composer install` then run PHPUnit with `./vendor/bin/phpunit` to execute all of the integration tests.

Documentation
-------------

[](#documentation)

General TozStore documentation is [on our developer site](https://developers.tozny.com).

Contributing
------------

[](#contributing)

Bug reports and pull requests are welcome on GitHub at .

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 65% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~284 days

Total

3

Last Release

2644d ago

### Community

---

Top Contributors

[![ericmann](https://avatars.githubusercontent.com/u/605474?v=4)](https://github.com/ericmann "ericmann (13 commits)")[![eddier](https://avatars.githubusercontent.com/u/1723648?v=4)](https://github.com/eddier "eddier (5 commits)")[![SyntaxPolice](https://avatars.githubusercontent.com/u/564819?v=4)](https://github.com/SyntaxPolice "SyntaxPolice (2 commits)")

---

Tags

api-clientencrypted-storeencryptionphp

### Embed Badge

![Health badge](/badges/tozny-e3db/health.svg)

```
[![Health](https://phpackages.com/badges/tozny-e3db/health.svg)](https://phpackages.com/packages/tozny-e3db)
```

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[roave/security-advisories

Prevents installation of composer packages with known security vulnerabilities: no API, simply require it

2.9k97.3M6.4k](/packages/roave-security-advisories)[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k16.7M113](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41278.1M118](/packages/robrichards-xmlseclibs)[bjeavons/zxcvbn-php

Realistic password strength estimation PHP library based on Zxcvbn JS

86917.5M63](/packages/bjeavons-zxcvbn-php)[enlightn/security-checker

A PHP dependency vulnerabilities scanner based on the Security Advisories Database.

33732.2M110](/packages/enlightn-security-checker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
