This package provides an implementation of the RFC 4506 External Data Representation standard for PHP. It is built to be extensible; you can encode and decode custom data objects as well as primitive generics.
This package is currently in beta; the API is still subject to change.
Important Note: Quadruple-Precision Floating-Point numbers are not supported by this package as a native type. However tools are provided for you to implement this in your own project should you have the need.
You can install the package via composer:
composer require stagerightlabs/phpxdr
use StageRightLabs\PhpXdr\XDR;
// Encode
$xdr = XDR::fresh()
->write(42, XDR::INT)
->write(3.14, XDR::FLOAT)
->write('Bad Wolf', XDR::STRING);
$payload = $xdr->asBase64(); // AAAAKkBI9cMAAAAIQmFkIFdvbGY=
// Decode
$xdr = XDR::fromBase64('AAAAKkBI9cMAAAAIQmFkIFdvbGY=');
$int = $xdr->read(XDR::INT); // 42
$float = $xdr->read(XDR::FLOAT); // ~3.14
$string = $xdr->read(XDR::STRING); // 'Bad Wolf'
More implementation and usage details can be found in the wiki.
./vendor/bin/phpunit
This package draws a lot of inspiration from both zulucrypto/stellar-api and stellar/js-xdr.
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The Apache License 2. Please see License File for more information.
This package was generated using the PHP Package Boilerplate by Beyond Code.