2017 © Pedro Peláez
 

library avro-php

Implementation of Apache's Avro PHP library with Composer support, PSR-4 autoloading, namespaces, and type hinted method parameters

image

sparhandy/avro-php

Implementation of Apache's Avro PHP library with Composer support, PSR-4 autoloading, namespaces, and type hinted method parameters

  • Monday, April 23, 2018
  • by Sparhandy
  • Repository
  • 11 Watchers
  • 1 Stars
  • 75 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 12 Versions
  • 15 % Grown

The README.md

Sparhandy/avro-php

This is a package based on the Apache AVRO PHP library (v 1.8.1)., (*1)

The core logic remains the same but I've added Composer support, PSR-4 autoloading, method type-hinting, fixed property accessors with encapsulation where I've found errors (private/public member access), and some other tidy-ups., (*2)

Usage

Installation

$ composer require sparhandy/avro-php

Usage

Based on the official library's example:, (*3)

<?php

use Avro\DataIO\DataIO;
use Avro\DataIO\DataIOReader;
use Avro\DataIO\DataIOWriter;
use Avro\Datum\IODatumReader;
use Avro\Datum\IODatumWriter;
use Avro\IO\StringIO;
use Avro\Schema\Schema;

require_once('vendor/autoload.php');

$writers_schema_json = <<<_JSON
{
 "name":"member",
 "type":"record",
 "fields":
    [
        {"name":"member_id", "type":"int"},
        {"name":"member_name", "type":"string"}
    ]
}
_JSON;

$jose = array('member_id' => 1392, 'member_name' => 'Jose');
$maria = array('member_id' => 1642, 'member_name' => 'Maria');
$data = array($jose, $maria);


$file_name = 'data.avr';

// Open $file_name for writing, using the given writer's schema
$data_writer = DataIO::open_file($file_name, 'w', $writers_schema_json);
// Write each datum to the file
foreach ($data as $datum) {
    $data_writer->append($datum);
}
$data_writer->close();


// Open $file_name (by default for reading) using the writer's schema
// included in the file
$data_reader = DataIO::open_file($file_name);
echo "from file:\n";
// Read each datum
foreach ($data_reader->data() as $datum) {
    echo var_export($datum, true) . "\n";
}
$data_reader->close();


$io = new StringIO();

$writers_schema = Schema::parse($writers_schema_json);
$data_writer = new DataIOWriter($io, new IODatumWriter($writers_schema), $writers_schema);

foreach ($data as $datum) {
    $data_writer->append($datum);
}
$data_writer->close();


$binary_string = $io->string();

// Load the string data string
$read_io = new StringIO($binary_string);
$data_reader = new DataIOReader($read_io, new IODatumReader());
echo "from binary string:\n";
foreach ($data_reader->data() as $datum) {
    echo var_export($datum, true) . "\n";
}

The Versions

23/04 2018

dev-master

9999999-dev

Implementation of Apache's Avro PHP library with Composer support, PSR-4 autoloading, namespaces, and type hinted method parameters

  Sources   Download

proprietary

The Requires

  • php ^7.2

 

The Development Requires

by Philipp Witzmann
by Andreas Grzywatz

23/04 2018

0.1.10

0.1.10.0

Implementation of Apache's Avro PHP library with Composer support, PSR-4 autoloading, namespaces, and type hinted method parameters

  Sources   Download

proprietary

The Requires

  • php ^7.2

 

The Development Requires

by Philipp Witzmann
by Andreas Grzywatz

23/04 2018

0.1.8

0.1.8.0

Implementation of Apache's Avro PHP library with Composer support, PSR-4 autoloading, namespaces, and type hinted method parameters

  Sources   Download

proprietary

The Requires

  • php ^7.2

 

The Development Requires

by Philipp Witzmann
by Andreas Grzywatz

23/04 2018

0.1.9

0.1.9.0

Implementation of Apache's Avro PHP library with Composer support, PSR-4 autoloading, namespaces, and type hinted method parameters

  Sources   Download

proprietary

The Requires

  • php ^7.2

 

The Development Requires

by Philipp Witzmann
by Andreas Grzywatz

23/04 2018

0.1.7

0.1.7.0

Implementation of Apache's Avro PHP library with Composer support, PSR-4 autoloading, namespaces, and type hinted method parameters

  Sources   Download

proprietary

The Requires

  • php ^7.2

 

The Development Requires

by Philipp Witzmann
by Andreas Grzywatz

16/04 2018

0.1.6

0.1.6.0

Implementation of Apache's Avro PHP library with Composer support, PSR-4 autoloading, namespaces, and type hinted method parameters

  Sources   Download

proprietary

The Requires

  • php ^7.2

 

The Development Requires

by Philipp Witzmann
by Andreas Grzywatz

27/03 2018

0.1.5

0.1.5.0

Implementation of Apache's Avro PHP library with Composer support, PSR-4 autoloading, namespaces, and type hinted method parameters

  Sources   Download

proprietary

The Requires

  • php ^7.2

 

The Development Requires

by Philipp Witzmann
by Andreas Grzywatz

23/03 2018

0.1.4

0.1.4.0

Implementation of Apache's Avro PHP library with Composer support, PSR-4 autoloading, namespaces, and type hinted method parameters

  Sources   Download

The Requires

  • php ^7.2

 

The Development Requires

07/03 2018

0.1.3

0.1.3.0

Implementation of Apache's Avro PHP library with Composer support, PSR-4 autoloading, namespaces, and type hinted method parameters

  Sources   Download

30/01 2017

0.1.2

0.1.2.0

Implementation of Apache's Avro PHP library with Composer support, PSR-4 autoloading, namespaces, and type hinted method parameters

  Sources   Download

30/01 2017

0.1.0

0.1.0.0

  Sources   Download

30/01 2017

0.1.1

0.1.1.0

  Sources   Download