mateusjunges/avro-serde-php
PHP 7.3+/8 Avro serializer/deserializer implementing Confluent wire format with Schema Registry integration. Supports schema evolution via Confluent compatibility policies and works with FlixTech’s schema-registry-php-client (recommended with caching).
Begin by installing the package via Composer: composer require mateusjunges/avro-serde-php. Next, review the README — it provides a minimal Symfony Serializer setup example. The primary entry point is the AvroSerializer class, which integrates with Symfony’s Serializer component. To serialize/deserialize an object, ensure your schema is defined (e.g., as a JSON file or inline string), load it into an AvroSchema, and pass both the schema and your object to the AvroSerializer. The first common use case is serializing domain objects to Avro binary format for use with Kafka or schema-registries.
schemas/user.avsc) and load them via AvroSchema::loadJsonFile() or use inline schema strings for simple cases.AvroSerializer as a service and tag it with serializer.normalizer so it integrates with Symfony’s Serializer stack automatically.SchemaRegistrySerializer to resolve schema IDs dynamically from a remote registry (e.g., Confluent Schema Registry). Cache schema lookups using Symfony’s Cache component for performance.public string $name;) and let the serializer handle type conversion and validation based on the Avro schema.SchemaResolutionException. Use default values and unions (e.g., ["null", "string"]) for forward/backward compatibility.false to AvroSerializer::encode() to get binary; when debugging, set true to get base64-encoded strings.Schema instance. In long-running processes (e.g., Laravel Horizon jobs), cache schemas in static properties or services.AvroSerializer::setLogger() with a PSR-3 logger to capture resolution errors. Check stack traces for schema mismatch details — the error message often includes expected vs actual field names/types.int → long, string → enum), but PHP strict typing may fail before Avro gets a chance — disable strict types (declare(strict_types=0)) in serializers if integrating with strongly-typed code.How can I help you explore Laravel packages today?