PHPackages                             auxmoney/avro-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. auxmoney/avro-php

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

auxmoney/avro-php
=================

Avro schema encoder/decoder

v1.0.0(4mo ago)314.1k↓20.2%3Apache-2.0PHPCI passing

Since Jan 10Pushed 4mo ago2 watchersCompare

[ Source](https://github.com/auxmoney/avro-php)[ Packagist](https://packagist.org/packages/auxmoney/avro-php)[ RSS](/packages/auxmoney-avro-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (5)Versions (11)Used By (0)

auxmoney/avro-php
=================

[](#auxmoneyavro-php)

A PHP library that provides schema-based Avro data serialization and deserialization.

Key features:

- Support for logical types
- Developer-friendly error messages for schema validation
- Schema resolution including promotion of primitive types
- Serialization of objects through getters or public properties
- Default values for record fields
- Configurable block count and block size for array and map encoding

Installation
------------

[](#installation)

To install auxmoney/avro-php, you can use Composer:

```
composer require auxmoney/avro-php
```

Usage
-----

[](#usage)

### Encoding/Decoding Data

[](#encodingdecoding-data)

Try out the example scripts:

```
php examples/encoding.php
php examples/decoding.php
php examples/logical-type.php
```

### Logical Types

[](#logical-types)

It is possible to configure logical types in a few different ways:

#### Using Default Logical Types

[](#using-default-logical-types)

There are built-in implementations for all logical types described in the AVRO specification, except for `timestamp-nanos` and `local-timestamp-nanos`, because PHP's DateTime doesn't have nanosecond precision.

To use the default logical types, simply create an AvroFactory without any options:

```
$avroFactory = AvroFactory::create();
```

#### Overriding Logical Types

[](#overriding-logical-types)

You can override default logical types or add custom ones by providing factory implementations:

```
$defaultLogicalTypeFactories = AvroFactory::getDefaultLogicalTypeFactories();
$defaultLogicalTypeFactories['custom'] = new MyCustomLogicalTypeFactory();
$options = new Options(logicalTypeFactories: $defaultLogicalTypeFactories);
$avroFactory = AvroFactory::create($options);
```

#### Disabling Logical Types

[](#disabling-logical-types)

To disable all logical type processing and treat them as their underlying primitive types:

```
$options = new Options(logicalTypeFactories: []);
$avroFactory = AvroFactory::create($options);
```

### Value Objects for Logical Types

[](#value-objects-for-logical-types)

Some logical types work with their respective value objects to provide type safety and better representation of the data:

- `decimal`: `Auxmoney\Avro\ValueObject\Decimal`
- `duration`: `Auxmoney\Avro\ValueObject\Duration`
- `time-millis`: `Auxmoney\Avro\ValueObject\TimeOfDay`
- `time-micros`: `Auxmoney\Avro\ValueObject\TimeOfDay`
- `uuid`: `Auxmoney\Avro\ValueObject\Uuid`

The `local-timestamp-*` and `timestamp-*` types are serialized from/deserialized to `DateTimeInterface`.

Documentation
-------------

[](#documentation)

For more detailed documentation on usage, schema design, and advanced features like schema evolution, please refer to the official Avro documentation.

Contribution
------------

[](#contribution)

Contributions are welcome! If you find a bug or want to suggest a new feature, feel free to open an issue or submit a pull request.

Development Setup
-----------------

[](#development-setup)

This project uses VS Code Dev Containers for development. This ensures a consistent development environment across all contributors.

### Using VS Code Dev Container (Recommended)

[](#using-vs-code-dev-container-recommended)

1. Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) in VS Code
2. Open the project in VS Code
3. When prompted, click "Reopen in Container" or use `Ctrl+Shift+P` → "Dev Containers: Reopen in Container"

The container includes:

- PHP 8.3 with Xdebug
- Composer for dependency management
- PHPUnit for testing
- Node.js for test generation tools
- Git and GitHub CLI

### Manual Docker Usage

[](#manual-docker-usage)

You can also use the containers manually:

```
# Using the convenience script (recommended)
./docker-dev run --rm dev
./docker-dev run --rm dev vendor/bin/phpunit
./docker-dev run --rm test-generator

# Or using docker compose directly
docker compose -f .devcontainer/docker-compose.yaml run --rm dev
docker compose -f .devcontainer/docker-compose.yaml run --rm dev vendor/bin/phpunit
docker compose -f .devcontainer/docker-compose.yaml run --rm test-generator
```

For more details, see [.devcontainer/README.md](.devcontainer/README.md).

License
-------

[](#license)

This library is licensed under the Apache License 2.0.

Changelog
---------

[](#changelog)

For the detailed changelog, please refer to the Releases page.

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance77

Regular maintenance activity

Popularity32

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~61 days

Recently: every ~50 days

Total

7

Last Release

124d ago

Major Versions

v0.1.3 → v1.0.02026-01-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/58fb41ad66c6b45096cad21d54aa1aacabcb9eedc8974664e1e6776327662816?d=identicon)[cawolf](/maintainers/cawolf)

![](https://www.gravatar.com/avatar/8c532f151bbf9c52f35ecbb5d1678d0216bf112c211468e91001b29a09d9e733?d=identicon)[guckykv](/maintainers/guckykv)

![](https://www.gravatar.com/avatar/b4068ca7fee9c9013abf65009886906424f14c64072e9775b6fb861c9d91c75e?d=identicon)[thiagorb](/maintainers/thiagorb)

---

Top Contributors

[![thiagorb](https://avatars.githubusercontent.com/u/821208?v=4)](https://github.com/thiagorb "thiagorb (85 commits)")[![siad007](https://avatars.githubusercontent.com/u/2149445?v=4)](https://github.com/siad007 "siad007 (11 commits)")[![cutting](https://avatars.githubusercontent.com/u/270714?v=4)](https://github.com/cutting "cutting (6 commits)")[![sekikn](https://avatars.githubusercontent.com/u/898388?v=4)](https://github.com/sekikn "sekikn (5 commits)")[![auxmoney-tbarcala](https://avatars.githubusercontent.com/u/92433343?v=4)](https://github.com/auxmoney-tbarcala "auxmoney-tbarcala (2 commits)")[![nielsbasjes](https://avatars.githubusercontent.com/u/240096?v=4)](https://github.com/nielsbasjes "nielsbasjes (2 commits)")[![sjunior-dev](https://avatars.githubusercontent.com/u/799517?v=4)](https://github.com/sjunior-dev "sjunior-dev (1 commits)")[![auxdsimon](https://avatars.githubusercontent.com/u/133212638?v=4)](https://github.com/auxdsimon "auxdsimon (1 commits)")[![tomwhite](https://avatars.githubusercontent.com/u/85085?v=4)](https://github.com/tomwhite "tomwhite (1 commits)")[![ept](https://avatars.githubusercontent.com/u/27544?v=4)](https://github.com/ept "ept (1 commits)")[![jonhkr](https://avatars.githubusercontent.com/u/767866?v=4)](https://github.com/jonhkr "jonhkr (1 commits)")[![MichelHartmann](https://avatars.githubusercontent.com/u/274451?v=4)](https://github.com/MichelHartmann "MichelHartmann (1 commits)")[![mpetrovickg](https://avatars.githubusercontent.com/u/9052008?v=4)](https://github.com/mpetrovickg "mpetrovickg (1 commits)")[![RyanSkraba](https://avatars.githubusercontent.com/u/7744819?v=4)](https://github.com/RyanSkraba "RyanSkraba (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/auxmoney-avro-php/health.svg)

```
[![Health](https://phpackages.com/badges/auxmoney-avro-php/health.svg)](https://phpackages.com/packages/auxmoney-avro-php)
```

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97513.5M170](/packages/hassankhan-config)[meyfa/php-svg

Read, edit, write, and render SVG files with PHP

54613.9M42](/packages/meyfa-php-svg)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
