{"id":34004420,"url":"https://github.com/tozny/e3db-php","last_synced_at":"2026-04-01T23:02:43.959Z","repository":{"id":57072228,"uuid":"95512361","full_name":"tozny/e3db-php","owner":"tozny","description":"PHP client library for TozStore","archived":false,"fork":false,"pushed_at":"2019-10-24T16:47:54.000Z","size":186,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":8,"default_branch":"master","last_synced_at":"2026-03-28T00:58:08.144Z","etag":null,"topics":["api-client","encrypted-store","encryption","php"],"latest_commit_sha":null,"homepage":"https://tozny.com/tozstore/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tozny.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-27T03:09:49.000Z","updated_at":"2020-12-15T16:09:25.000Z","dependencies_parsed_at":"2022-08-24T14:54:34.141Z","dependency_job_id":null,"html_url":"https://github.com/tozny/e3db-php","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/tozny/e3db-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tozny%2Fe3db-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tozny%2Fe3db-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tozny%2Fe3db-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tozny%2Fe3db-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tozny","download_url":"https://codeload.github.com/tozny/e3db-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tozny%2Fe3db-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31292785,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T21:15:39.731Z","status":"ssl_error","status_checked_at":"2026-04-01T21:15:34.046Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","encrypted-store","encryption","php"],"created_at":"2025-12-13T10:05:14.546Z","updated_at":"2026-04-01T23:02:43.949Z","avatar_url":"https://github.com/tozny.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"![PHP 7.0+][php-image] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Packagist][packagist-image]][packagist-url]\n\n# Introduction\n\nTozStore (formerly E3DB) is a storage platform with powerful sharing and consent management features.\n[Read more on our web site.](https://tozny.com/tozstore/)\n\nTozStore provides a familiar JSON-based NoSQL-style API for reading, writing, and querying data stored securely in the cloud.\n\n# Installation\n\n## Composer\n\nTo install with composer add the following to your `composer.json` file:\n\n```\n\"require\": {\n    \"tozny/e3db\": \"1.2.0\"\n}\n```\n\nThen run `php composer.phar install`\n\n## Registering a client\n\nRegister 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.\n\nFor a more complete walkthrough, see [`/examples/registration.php`](https://github.com/tozny/e3db-php/blob/master/examples/registration.php).\n\n### Without Credential Backup\n\n```php\n$token = '...';\n$client_name = '...';\n\nlist($public_key, $private_key) = \\Tozny\\E3DB\\Client::generate_keypair();\n$client_info = \\Tozny\\E3DB\\Client::register($token, $client_name, $public_key);\n```\n\nThe 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.\n\n### With Credential Backup\n\n```php\n$token = '...';\n$client_name = '...';\n\nlist($public_key, $private_key) = \\Tozny\\E3DB\\Client::generate_keypair();\n$client_info = \\Tozny\\E3DB\\Client::register($token, $client_name, $public_key, $private_key, true);\n```\n\nThe 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.\n\n## Loading configuration and creating a client\n\nConfiguration is managed at runtime by instantiating a `Tozny\\E3DB\\Config` object with your client's credentials.\n\n```php\n/**\n * Assuming your credentials are stored as defined constants in the\n * application, pass them each into the configuration constructor as\n * follows:\n */\n$config = new \\Tozny\\E3DB\\Config(\n  CLIENT_ID,\n  API_KEY_ID,\n  API_SECRET,\n  PUBLIC_KEY,\n  PRIVATE_KEY,\n  API_URL\n);\n\n/**\n * Pass the configuration to the default coonection handler, which\n * uses Guzzle for requests. If you need a different library for\n * requests, subclass `\\Tozny\\E3DB\\Connection` and pass an instance\n * of your custom implementation to the client instead.\n */\n$connection = new \\Tozny\\E3DB\\Connection\\GuzzleConnection($config);\n\n/**\n * Pass both the configuration and connection handler when building\n * a new client instance.\n */\n$client = new \\Tozny\\E3DB\\Client($config, $connection);\n```\n\n# Usage\n\n## Writing a record\n\nTo 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.\n\n```php\n$record = $client-\u003ewrite('contact', [\n  'first_name' =\u003e 'Jon',\n  'last_name'  =\u003e 'Snow',\n  'phone'      =\u003e '555-555-1212',\n]);\n\necho sprintf(\"Wrote record %s\\n\", $record-\u003emeta-\u003erecord_id);\n```\n\n## Querying records\n\nE3DB 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`.\n\nFor example, to list all records of type `contact` and print a simple report containing names and phone numbers:\n\n```php\n$data = true;\n$raw = false;\n$writer = null;\n$record = null;\n$type = 'contact';\n\n$records = $client-\u003equery($data, $raw, $writer, $record, $type);\nforeach($records as $record) {\n  $fullname = $record-\u003edata['first_name'] . ' ' . $record-\u003edata['last_name'];\n  echo sprintf(\"%-40s %s\\n\", $fullname, $record-\u003edata['phone']);\n}\n```\n\nIn this example, the `Tozny\\E3DB\\Client::query` method returns an iterator that contains each record that matches the query.\n\n## More examples\n\nSee [the simple example code](https://github.com/tozny/e3db-php/blob/master/examples/simple.php) for runnable detailed examples.\n\n# Development\n\nBefore running tests, create a registration token through your [Tozny account](https://dashboard.tozny.com/register).\n\nStore 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.\n\nAfter checking out the repo, install dependencies using `composer install` then run PHPUnit with `./vendor/bin/phpunit` to execute all of the integration tests.\n\n## Documentation\n\nGeneral TozStore documentation is [on our developer site](https://developers.tozny.com).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/tozny/e3db-php.\n\n[php-image]: https://img.shields.io/badge/php-7.0%2B-green.svg\n[packagist-image]: https://img.shields.io/packagist/dt/tozny/e3db.svg\n[packagist-url]: https://packagist.org/packages/tozny/e3db\n[travis-image]: https://travis-ci.org/tozny/e3db-php.svg?branch=master\n[travis-url]: https://travis-ci.org/tozny/e3db-php\n[coveralls-image]: https://coveralls.io/repos/github/tozny/e3db-php/badge.svg?branch=master\n[coveralls-url]: https://coveralls.io/github/tozny/e3db-php\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftozny%2Fe3db-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftozny%2Fe3db-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftozny%2Fe3db-php/lists"}