https://github.com/stagerightlabs/phpxdr
Read and Write XDR with PHP
https://github.com/stagerightlabs/phpxdr
php rfc-4506 xdr
Last synced: 3 months ago
JSON representation
Read and Write XDR with PHP
- Host: GitHub
- URL: https://github.com/stagerightlabs/phpxdr
- Owner: stagerightlabs
- License: apache-2.0
- Created: 2021-11-13T05:31:45.000Z (over 3 years ago)
- Default Branch: dev
- Last Pushed: 2023-11-11T01:31:11.000Z (over 1 year ago)
- Last Synced: 2025-01-14T00:36:11.874Z (5 months ago)
- Topics: php, rfc-4506, xdr
- Language: PHP
- Homepage:
- Size: 103 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README

[](https://packagist.org/packages/stagerightlabs/phpxdr)
[](https://packagist.org/packages/stagerightlabs/phpxdr)
This package provides an implementation of the [RFC 4506](https://datatracker.ietf.org/doc/html/rfc4506.html) 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](https://datatracker.ietf.org/doc/html/rfc4506.html#section-4.8) 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.
## Installation
You can install the package via composer:
```bash
composer require stagerightlabs/phpxdr
```## Usage
```php
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](https://github.com/stagerightlabs/phpxdr/wiki).
### Testing
```bash
./vendor/bin/phpunit
```### Credits
This package draws a lot of inspiration from both [zulucrypto/stellar-api](https://github.com/zulucrypto/stellar-api) and [stellar/js-xdr](https://github.com/stellar/js-xdr).
### Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
### Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
## License
The Apache License 2. Please see [License File](LICENSE.md) for more information.
## PHP Package Boilerplate
This package was generated using the [PHP Package Boilerplate](https://laravelpackageboilerplate.com) by [Beyond Code](http://beyondco.de/).