lukecurtis93/avro-generate

Easily create Avro files from your PHP classes.

0.0.2 2022-12-13 14:52 UTC

README

Latest Version on Packagist Tests Total Downloads

Avro Generate is a small PHP CLI Application to allow you generate Avro definitions from your classes.

To use this package, simply implement the Avroable interface and define your definitions as per the Flixtech package

use FlixTech\AvroSerializer\Objects\Schema\Generation\Annotations;
use LukeCurtis\AvroGenerate\Contracts\Avroable;

/**
 * @Annotations\AvroType("record")
 * @Annotations\AvroName("user")
 */
class User implements Avroable
{
        /**
         * @Annotations\AvroType("string")
         * @var string
         */
        private $firstName;
//

Then you can run

./vendor/bin/avro generate --output=./resources/avro

This will generate the Avro schemas for your Avroable classes.

Coming Soon

  • Specify directories or explicit files for generation.
  • Upload these Avro files to a Schema Registry.
  • Checking for namesapces to be compatible with Confluent Schema Registry and UI.
  • Versioned schemas

Installation

You can install the package via composer:

composer require lukecurtis93/avro-generate

Usage

If you want to use the underlying generator for your own needs you can simply import and use the class.

$generator = new LukeCurtis\DefaultAvroGenerator();
echo $generator->generate();

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.