{"id":13579274,"url":"https://github.com/flix-tech/schema-registry-php-client","last_synced_at":"2025-09-04T20:56:52.991Z","repository":{"id":22462003,"uuid":"95291944","full_name":"flix-tech/schema-registry-php-client","owner":"flix-tech","description":"A PHP 8+ API client for the Confluent Schema Registry REST API based on Guzzle 7 - http://docs.confluent.io/current/schema-registry/docs/index.html","archived":false,"fork":false,"pushed_at":"2024-09-03T21:38:04.000Z","size":274,"stargazers_count":48,"open_issues_count":12,"forks_count":24,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-07-29T09:38:13.384Z","etag":null,"topics":["api-client","avro","avro-schema","confluent","event-driven-architecture","guzzlehttp","php","schema-evolution","schema-registry"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flix-tech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-06-24T10:52:11.000Z","updated_at":"2025-05-09T14:34:01.000Z","dependencies_parsed_at":"2024-11-05T17:41:55.349Z","dependency_job_id":"07833a2f-edf7-4f87-9f20-8ffc6eba0656","html_url":"https://github.com/flix-tech/schema-registry-php-client","commit_stats":{"total_commits":148,"total_committers":11,"mean_commits":"13.454545454545455","dds":"0.28378378378378377","last_synced_commit":"87023aebb0393da62d932b9be49d0d891a52ae37"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/flix-tech/schema-registry-php-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flix-tech%2Fschema-registry-php-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flix-tech%2Fschema-registry-php-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flix-tech%2Fschema-registry-php-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flix-tech%2Fschema-registry-php-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flix-tech","download_url":"https://codeload.github.com/flix-tech/schema-registry-php-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flix-tech%2Fschema-registry-php-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273567738,"owners_count":25128635,"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","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","avro","avro-schema","confluent","event-driven-architecture","guzzlehttp","php","schema-evolution","schema-registry"],"created_at":"2024-08-01T15:01:37.956Z","updated_at":"2025-09-04T20:56:52.950Z","avatar_url":"https://github.com/flix-tech.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Confluent Schema Registry PHP API\n\n[![schema-registry-ci Actions Status](https://github.com/flix-tech/schema-registry-php-client/workflows/schema-registry-ci/badge.svg?branch=master)](https://github.com/flix-tech/schema-registry-php-client/actions)\n[![Maintainability](https://api.codeclimate.com/v1/badges/e62d0c58bb72020eaf3c/maintainability)](https://codeclimate.com/github/flix-tech/schema-registry-php-client/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/e62d0c58bb72020eaf3c/test_coverage)](https://codeclimate.com/github/flix-tech/schema-registry-php-client/test_coverage)\n[![Latest Stable Version](https://poser.pugx.org/flix-tech/confluent-schema-registry-api/v/stable)](https://packagist.org/packages/flix-tech/confluent-schema-registry-api)\n[![Total Downloads](https://poser.pugx.org/flix-tech/confluent-schema-registry-api/downloads)](https://packagist.org/packages/flix-tech/confluent-schema-registry-api)\n[![License](https://poser.pugx.org/flix-tech/confluent-schema-registry-api/license)](https://packagist.org/packages/flix-tech/confluent-schema-registry-api)\n\nA PHP 7.4+ library to consume the Confluent Schema Registry REST API. It provides low level functions to create PSR-7\ncompliant requests that can be used as well as high level abstractions to ease developer experience.\n\n#### Contents\n\n- [Requirements](#requirements)\n  - [Hard Dependencies](#hard-dependencies)\n  - [Optional Dependencies](#optional-dependencies)\n- [Installation](#installation)\n- [Compatibility](#compatibility)\n- [Usage](#usage)\n  - [Asynchronous API](#asynchronous-api)\n  - [Synchronous API](#synchronous-api)\n  - [Caching](#caching)\n  - [Low Level API](#low-level-api)\n- [Testing](#testing)\n  - [Unit tests, Coding standards and static analysis](#unit-tests-coding-standards-and-static-analysis)\n  - [Integration tests](#integration-tests)\n- [Contributing](#contributing)\n\n## Requirements\n\n### Hard dependencies\n\n| Dependency | Version | Reason |\n|:--- |:---:|:--- |\n| **`php`** | ~7.4 | Anything lower has reached EOL |\n| **`guzzlephp/guzzle`** | ~7.0 | Using `Request` to build PSR-7 `RequestInterface` |\n| **`beberlei/assert`** | ~2.7\\|~3.0 | The de-facto standard assertions library for PHP |\n| **`flix-tech/avro-php`** | ^4.1 | Maintained fork of the only Avro PHP implementation: `rg/avro-php` |\n\n### Optional dependencies\n\n| Dependency | Version | Reason |\n|:--- |:---:|:--- |\n| **`doctrine/cache`** | ~1.3 | If you want to use the `DoctrineCacheAdapter` |\n| **`psr/cache`** | ^1.0 | If you want to use the `CacheItemPoolAdapter` |\n| **`psr/simple-cache`** | ^1.0 | If you want to use the `SimpleCacheAdapter` |\n\n## Installation\n\nThis library is installed via [`composer`](http://getcomposer.org).\n\n```bash\ncomposer require \"flix-tech/confluent-schema-registry-api=^7.4\"\n```\n\n\u003e **NOTE**\n\u003e\n\u003e If you are still running on a version less than `5.0.3` we recommend updating it immediately since there was a critical\n\u003e bug with the exception handling.\n\n## Compatibility\n\nThis library follows strict semantic versioning, so you can expect any minor and patch release to be compatible, while\nmajor version upgrades will have incompatibilities that will be released in the UPGRADE.md file.\n\n\n## Usage\n\n### Asynchronous API\n\n[Interface declaration](src/AsynchronousRegistry.php)\n\n#### Example `PromisingRegistry`\n\n```php\n\u003c?php\n\nuse GuzzleHttp\\Client;\nuse FlixTech\\SchemaRegistryApi\\Registry\\PromisingRegistry;\nuse FlixTech\\SchemaRegistryApi\\Exception\\SchemaRegistryException;\n\n$registry = new PromisingRegistry(\n    new Client(['base_uri' =\u003e 'registry.example.com'])\n);\n\n// Register a schema with a subject\n$schema = AvroSchema::parse('{\"type\": \"string\"}');\n\n// The promise will either contain a schema id as int when fulfilled,\n// or a SchemaRegistryException instance when rejected.\n// If the subject does not exist, it will be created implicitly\n$promise = $registry-\u003eregister('test-subject', $schema);\n\n// If you want to resolve the promise, you might either get the value or an instance of a SchemaRegistryException\n// It is more like an Either Monad, since returning Exceptions from rejection callbacks will throw them.\n// We want to leave that decision to the user of the lib.\n// TODO: Maybe return an Either Monad instead\n$promise = $promise-\u003ethen(\n    static function ($schemaIdOrSchemaRegistryException) {\n        if ($schemaIdOrSchemaRegistryException instanceof SchemaRegistryException) {\n            throw $schemaIdOrSchemaRegistryException;\n        }\n        \n        return $schemaIdOrSchemaRegistryException;\n    }\n);\n\n// Resolve the promise\n$schemaId = $promise-\u003ewait();\n\n// Get a schema by schema id\n$promise = $registry-\u003eschemaForId($schemaId);\n// As above you could add additional callbacks to the promise\n$schema = $promise-\u003ewait();\n\n// Get the version of a schema for a given subject.\n$version = $registry-\u003eschemaVersion(\n    'test-subject',\n    $schema\n)-\u003ewait();\n\n// You can also get a schema by subject and version\n$schema = $registry-\u003eschemaForSubjectAndVersion('test-subject', $version)-\u003ewait();\n\n// You can additionally just query for the currently latest schema within a subject.\n// *NOTE*: Once you requested this it might not be the latest version anymore.\n$latestSchema = $registry-\u003elatestVersion('test-subject')-\u003ewait();\n\n// Sometimes you want to find out the global schema id for a given schema\n$schemaId = $registry-\u003eschemaId('test-subject', $schema)-\u003ewait();\n```\n\n### Synchronous API\n\n[Interface declaration](src/SynchronousRegistry.php)\n\n#### Example `BlockingRegistry`\n\n```php\n\u003c?php\n\nuse FlixTech\\SchemaRegistryApi\\Registry\\BlockingRegistry;\nuse FlixTech\\SchemaRegistryApi\\Registry\\PromisingRegistry;\nuse GuzzleHttp\\Client;\n\n$registry = new BlockingRegistry(\n    new PromisingRegistry(\n        new Client(['base_uri' =\u003e 'registry.example.com'])\n    )\n);\n\n// What the blocking registry does is actually resolving the promises\n// with `wait` and adding a throwing rejection callback.\n$schema = AvroSchema::parse('{\"type\": \"string\"}');\n\n// This will be an int, and not a promise\n$schemaId = $registry-\u003eregister('test-subject', $schema);\n```\n\n### Caching\n\nThere is a `CachedRegistry` that accepts a `CacheAdapter` together with a `Registry`.\nIt supports both async and sync APIs.\n\n\u003e **NOTE:**\n\u003e\n\u003e From version 4.x of this library the API for the `CacheAdapterInterface` has been changed in order to allow caching\n\u003e of schema ids by hash of a given schema.\n\n#### Example\n\n```php\n\u003c?php\n\nuse FlixTech\\SchemaRegistryApi\\Registry\\BlockingRegistry;\nuse FlixTech\\SchemaRegistryApi\\Registry\\PromisingRegistry;\nuse FlixTech\\SchemaRegistryApi\\Registry\\CachedRegistry;\nuse FlixTech\\SchemaRegistryApi\\Registry\\Cache\\AvroObjectCacheAdapter;\nuse FlixTech\\SchemaRegistryApi\\Registry\\Cache\\DoctrineCacheAdapter;\nuse Doctrine\\Common\\Cache\\ArrayCache;\nuse GuzzleHttp\\Client;\n\n$asyncApi = new PromisingRegistry(\n    new Client(['base_uri' =\u003e 'registry.example.com'])\n);\n\n$syncApi = new BlockingRegistry($asyncApi);\n\n$doctrineCachedSyncApi = new CachedRegistry(\n    $asyncApi,\n    new DoctrineCacheAdapter(\n        new ArrayCache()\n    )\n);\n\n// All adapters support both APIs, for async APIs additional fulfillment callbacks will be registered.\n$avroObjectCachedAsyncApi = new CachedRegistry(\n    $syncApi,\n    new AvroObjectCacheAdapter()\n);\n\n// NEW in version 4.x, passing in custom hash functions to cache schema ids via the schema hash\n// By default the following function is used internally\n$defaultHashFunction = static function (AvroSchema $schema) {\n   return md5((string) $schema); \n};\n\n// You can also define your own hash callable\n$sha1HashFunction = static function (AvroSchema $schema) {\n   return sha1((string) $schema); \n};\n\n// Pass the hash function as optional 3rd parameter to the CachedRegistry constructor\n$avroObjectCachedAsyncApi = new CachedRegistry(\n    $syncApi,\n    new AvroObjectCacheAdapter(),\n    $sha1HashFunction\n);\n```\n\n### Low Level API\n\nThere is a low-level API that provides simple functions that return PSR-7 request objects for the different endpoints of\nthe registry. See [Requests/Functions](src/Requests/Functions.php) for more information.\n\nThere are also requests to use the new `DELETE` API of the schema registry.\n\n## Testing\n\nThis library uses a `Makefile` to run the test suite and requires `docker`.\n\nYou can set the default variables by copying `variables.mk.dist` to `variables.mk` and change them to your liking.\n\n#### Build the local docker image\n\n```bash\nPHP_VERSION=7.3 XDEBUG_VERSION=2.9.8 make docker\n```\n\n#### Unit tests, Coding standards and static analysis\n\n```bash\nPHP_VERSION=7.3 make ci-local\n```\n\n#### Integration tests\n\nThis library uses a `docker-compose` configuration to fire up a schema registry for integration testing, hence\n`docker-compose` from version 1.18.x is required to run those tests.\n\n##### The platform can be controlled with the following environment variables\n\n```\nCONFLUENT_VERSION=latest\nCONFLUENT_NETWORK_SUBNET=172.68.0.0/24\nSCHEMA_REGISTRY_IPV4=172.68.0.103\nKAFKA_BROKER_IPV4=172.68.0.102\nZOOKEEPER_IPV4=172.68.0.101\n```\n\n##### Building the confluent platform with a specific version and run the integration tests\n\n```bash\nCONFLUENT_VERSION=5.2.3 make platform\nmake phpunit-integration\nmake clean\n```\n\n## Contributing\n\nIn order to contribute to this library, follow this workflow:\n\n- Fork the repository\n- Create a feature branch\n- Work on the feature \n- Run tests to verify that the tests are passing\n- Open a PR to the upstream\n- Be happy about contributing to open source!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflix-tech%2Fschema-registry-php-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflix-tech%2Fschema-registry-php-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflix-tech%2Fschema-registry-php-client/lists"}