Download the PHP package curentis/openfga-php without Composer
On this page you can find all versions of the php package curentis/openfga-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download curentis/openfga-php
More information about curentis/openfga-php
Files in curentis/openfga-php
Package openfga-php
Short Description PHP SDK for OpenFGA — fine-grained, relationship-based authorization (Zanzibar-style).
License Apache-2.0
Homepage https://github.com/curentis/openfga-php
Informations about the package openfga-php
curentis/openfga-php
PHP SDK for OpenFGA — fine-grained, relationship-based authorization (Zanzibar-style).
This library targets production PHP applications: a typed high-level client (OpenFgaClientInterface), generated request/response models from the OpenFGA OpenAPI spec, PSR-18 HTTP with retries and error mapping, and extension points when you need custom write/batch-check behavior or a decorated client.
Install
Any PSR-18 HTTP client works (Guzzle, Symfony HttpClient, etc.). Optional: symfony/cache for PSR-16 OAuth token caching across PHP-FPM workers.
Requirements
| Component | Version |
|---|---|
| PHP | 8.3, 8.4, or 8.5 (SUPPORTED_RUNTIMES.md) |
| OpenFGA server | v1.10.0+ (integration tests also run against v1.21.0) |
Quickstart
Configuration
ClientConfiguration is the single place to wire URL, store context, credentials, HTTP stack, and optional factories:
| Option | Description |
|---|---|
apiUrl |
OpenFGA base URL (default http://localhost:8080) |
storeId / authorizationModelId |
Default ULIDs for store-scoped APIs (optional) |
credentials |
ApiToken, ClientCredentials, ClientAssertion, or NoCredentials |
tokenCache |
Optional PSR-16 cache for OAuth access tokens |
httpClient, requestFactory, streamFactory, uriFactory |
Override PSR-18 / PSR-17 discovery |
retry |
RetryOptions (max retries, backoff, wall-clock deadline, per-attempt cap) |
defaultHeaders |
Headers sent on every request |
componentFactory |
Custom write/batch-check runners and consistency body factory |
tokenCacheKey |
Optional 32-byte sodium key that encrypts cached OAuth tokens |
telemetry |
Optional PSR-3 logger and PSR-14 dispatcher |
Immutable helpers withStoreId() / withAuthorizationModelId() return a new client; per-call overrides use RequestOptions (store, model, headers). Details: docs/getting-started.md.
Authentication (summary)
See examples/authentication_api_token.php.
Features
Stores and authorization models
Create and manage stores; write and read authorization models; readLatestAuthorizationModel() for the newest model id in a store.
Tuples (writes)
write(),writeTuples(),deleteTuples()with transactional semantics by default.- Non-transactional mode and chunking via
WriteOptions+TransactionOptions. - Conflict policies via
ConflictOptions(on_duplicate,on_missing).
Checks and batch operations
check()with optionalConsistencyPreference.batchCheck()— automatic chunking (default max 50 checks per HTTP request, configurable).listRelations()— batch-check a list of relation names for one user/object pair.
Queries
read(),readChanges(),expand(),listObjects(),listUsers().streamedListObjects()— NDJSON stream of object ids.
Assertions and low-level API
readAssertions()/writeAssertions()for model tests.executeApiRequest()andexecuteStreamedApiRequest()— same transport, retries, and credentials as the rest of the SDK.
Full API walkthrough: docs/client-operations.md.
Customization
Depend on interfaces in your app; swap implementations without forking the SDK:
| Interface | Typical use |
|---|---|
OpenFgaClientInterface |
Application entry point; decorators for logging/metrics |
OpenFgaClientFactoryInterface |
Custom client wiring |
ClientComponentFactoryInterface |
Custom WriteRunner / BatchCheckRunner / consistency mapping |
OpenFgaApiInterface / TransportInterface |
Advanced HTTP or API wrapping |
Guide: examples/custom_components.php.
Documentation and examples
| Resource | Description |
|---|---|
| docs/README.md | Documentation index |
| docs/getting-started.md | Install, configuration, first checks |
| docs/authentication.md | Tokens and OAuth |
| docs/client-operations.md | Writes, batch check, consistency, raw requests |
| docs/customization.md | Extension interfaces |
| docs/error-handling.md | Exception hierarchy and partial writes |
| docs/production.md | Timeouts, retries, token cache, consistency |
| examples/README.md | Runnable scripts |
Development
On PHP 8.3 with locked dependencies, CI also enforces 100% line coverage (hand-written src/, excluding generated src/Model) and 100% Infection MSI.
Codegen from the vendored OpenAPI spec:
See AGENTS.md.
Acknowledgements
- OpenFGA and the official language SDKs.
- evansims/openfga-php (archived) — design inspiration; this is a clean-room implementation.
License
Apache-2.0 — see LICENSE.
All versions of openfga-php with dependencies
ext-json Version *
php-http/discovery Version ^1.19
psr/clock Version ^1.0
psr/event-dispatcher Version ^1.0
psr/http-client Version ^1.0
psr/http-client-implementation Version ^1.0
psr/http-factory Version ^1.0
psr/http-factory-implementation Version ^1.0
psr/http-message Version ^1.1 || ^2.0
psr/log Version ^3.0
psr/simple-cache Version ^2.0 || ^3.0