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 today

READMEChangelog (3)Dependencies (6)Versions (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

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community17

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

2691d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1895738?v=4)[Luke Woodward](/maintainers/lkwdwrd)[@lkwdwrd](https://github.com/lkwdwrd)

![](https://www.gravatar.com/avatar/d3772693102933b4813fc9d2f026443a3c78adcda06138e6eaf7ee1090fc0b72?d=identicon)[bentozny](/maintainers/bentozny)

![](https://avatars.githubusercontent.com/u/1723648?v=4)[Edward Raffaele](/maintainers/eddier)[@eddier](https://github.com/eddier)

---

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

###  Code Quality

TestsPHPUnit

### 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

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.2k532.1M2.5k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k33](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[dgtlss/warden

A Laravel package that proactively monitors your dependencies for security vulnerabilities by running automated composer audits and sending notifications via webhooks and email

9056.1k](/packages/dgtlss-warden)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

252.5k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

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