{"id":13521056,"url":"https://github.com/linkorb/spicedb-php","last_synced_at":"2025-04-22T20:32:00.266Z","repository":{"id":65142859,"uuid":"538933478","full_name":"linkorb/spicedb-php","owner":"linkorb","description":"Authz SpiceDB client library for PHP","archived":false,"fork":false,"pushed_at":"2025-02-14T11:39:44.000Z","size":175,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-31T07:35:08.862Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linkorb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-20T10:35:08.000Z","updated_at":"2025-02-14T11:39:25.000Z","dependencies_parsed_at":"2024-11-02T05:30:55.088Z","dependency_job_id":"a83b8aec-7633-4d04-afde-f99ab7eb1ab9","html_url":"https://github.com/linkorb/spicedb-php","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkorb%2Fspicedb-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkorb%2Fspicedb-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkorb%2Fspicedb-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkorb%2Fspicedb-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linkorb","download_url":"https://codeload.github.com/linkorb/spicedb-php/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250318817,"owners_count":21410994,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-08-01T06:00:27.451Z","updated_at":"2025-04-22T20:31:59.908Z","avatar_url":"https://github.com/linkorb.png","language":"PHP","funding_links":[],"categories":["Clients"],"sub_categories":["Third-party Libraries"],"readme":"# Authzed PHP Client\n\n[![Docs](https://img.shields.io/badge/docs-authzed.com-%234B4B6C \"Authzed Documentation\")](https://docs.authzed.com)\n\nThis repository houses the PHP client library for Authzed and SpiceDB.\n\n[SpiceDB] is a database system for managing security-critical permissions checking.\n\nSpiceDB acts as a centralized service that stores authorization data.\nOnce stored, data can be performantly queried to answer questions such as \"Does this user have access to this resource?\" and \"What are all the resources this user has access to?\".\n\n[Authzed] operates the globally available, serverless database platform for SpiceDB.\n\nSupported client API versions:\n- [v1](https://buf.build/authzed/api/docs/main/authzed.api.v1)\n\nYou can find more info about the API in the [Authzed Documentation API Reference] or the [Authzed API Buf Registry repository].\n\n[SpiceDB]: https://github.com/authzed/spicedb\n[Authzed]: https://authzed.com\n[Authzed Documentation API Reference]: https://docs.authzed.com/reference/api\n[Authzed API Buf Registry repository]: https://buf.build/authzed/api\n\n## Getting Started\n\nWe highly recommend following the **[Protecting Your First App]** guide to learn the latest best practice to integrate an application with Authzed.\n\n[Protecting Your First App]: https://docs.authzed.com/guides/first-app\n\n## Basic Usage\n\n### Installation\n\nUsing composer tool run:\n```shell\ncomposer require linkorb/spicedb-php\n```\n\n### Initializing a client\n\nSpiceDB connector depends on `symfony/serializer` and `symfony/http-client`. Instantiation of a new client with pure PHP can be done following way:\n```php\nuse Symfony\\Component\\HttpClient\\HttpClient;\nuse Symfony\\Component\\PropertyInfo\\Extractor\\ReflectionExtractor;\nuse Symfony\\Component\\Serializer\\Encoder\\JsonEncoder;\nuse LinkORB\\Authzed\\Serializer\\JsonLinesDecoder;\nuse Symfony\\Component\\Serializer\\Normalizer\\ArrayDenormalizer;\nuse Symfony\\Component\\Serializer\\Normalizer\\UnwrappingDenormalizer;\nuse Symfony\\Component\\Serializer\\Normalizer\\ObjectNormalizer;\nuse Symfony\\Component\\Serializer\\Serializer;\n\nnew SpiceDB(\n    new Serializer(\n        [new ArrayDenormalizer(), new UnwrappingDenormalizer(), new ObjectNormalizer(null, null, null, new ReflectionExtractor())],\n        [new JsonEncoder(), new JsonLinesDecoder()]\n    ),\n    HttpClient::create(),\n    getenv('SPICEDB_HOST'),\n    getenv('SPICEDB_API_KEY')\n);\n```\nFor Symfony apps there'll be a separate bundle which is currently WIP\n\n### Performing an API call\n\nSpiceDB connector implements communication through [REST API](https://app.swaggerhub.com/apis-docs/authzed/authzed/1.0#/). Check `LinkORB\\Authzed\\ConnectorInterface` for available methods. Here's example of write schema request:\n```php\n$client-\u003ewriteSchema(new \\LinkORB\\Authzed\\Dto\\Request\\Schema(\n    'definition blog/post {\n           relation reader: blog/user\n           relation writer: blog/user\n           permission read = reader + writer\n           permission write = writer\n    }\n    \n    definition blog/user {}'\n));\n```\n\n### Tests\nTests can be run with following command:\n```shell\nmake run-test\n```\nFor that you need to have [Docker](https://www.docker.com/) installed. Alternatively you can run test with PHP installed on host:\n```shell\nphpunit -c ./phpunit.xml --testsuite 'Integration' ./tests/\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkorb%2Fspicedb-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinkorb%2Fspicedb-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkorb%2Fspicedb-php/lists"}