nick-zh / php-avro-schema-generator
PHP avro schema generator for subschema
Installs: 1 947
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
Requires
- ext-json: *
- flix-tech/avro-php: ^3.0|^4.0
- symfony/console: ^4.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.15
- infection/infection: ^0.17
- phpstan/phpstan: ^0.12
- phpunit/phpunit: ^9.3
- rregeer/phpunit-coverage-check: ^0.3
- squizlabs/php_codesniffer: ^3.4.2
This package is auto-updated.
Last update: 2020-11-16 13:14:44 UTC
README
This package has been deprecated in favour of php-kafka/php-avro-schema-generator
Avro schema generator for PHP
Installation
composer require nick-zh/php-avro-schema-generator "^0.1.0"
Description
Since avro does not support external subschemas, this is just a small helper to unify your schemas and to create basic schemas from php classes (experimental!).
Merging subschemas / schemas
Schema template directories: directories containing avsc template files (with subschema) Output directory: output directory for the unified schema files
Merge subschemas (code)
<?php use NickZh\PhpAvroSchemaGenerator\Registry\SchemaRegistry; use NickZh\PhpAvroSchemaGenerator\Merger\SchemaMerger; $registry = (new SchemaRegistry()) ->addSchemaTemplateDirectory('./schemaTemplates') ->load(); $merger = new SchemaMerger($registry, './schema'); $merger->merge();
Merge subschemas (command)
./vendor/bin/avro-cli avro:subschema:merge ./example/schemaTemplates ./example/schema
Generating schemas from classes
Please note, that this feature is highly experimental.
You probably still need to adjust the generated templates, but it gives you a basic tempalte to work with.
Class direcotries: Directories containing the classes you want to generate schemas from
Output directory: output directory for your generated schema templates
Generate schemas (code)
<?php use NickZh\PhpAvroSchemaGenerator\Registry\ClassRegistry; use NickZh\PhpAvroSchemaGenerator\Generator\SchemaGenerator; $registry = (new ClassRegistry()) ->addClassDirectory('./example/classes') ->load(); $generator = new SchemaGenerator($registry, './example/schemaTemplates'); $schemas = $generator->generate(); $generator->exportSchemas($schemas);
Merge subschemas (command)
./vendor/bin/avro-cli avro:schema:generate ./example/classes ./example/schemaTemplates