petrocki / iof-xml-php
PHP model classes and XML serialization/deserialization tools for the IOF XML 3.0 data standard
v1.1.0
2026-07-13 19:31 UTC
Requires
- php: ^8.3
- goetas-webservices/xsd2php-runtime: ^0.2.18
- jms/serializer: ^3.32
Requires (Dev)
- ext-dom: *
- friendsofphp/php-cs-fixer: ^3.95
- goetas-webservices/xsd2php: ^0.4.14
- phpunit/phpunit: ^12.5
README
PHP model classes and XML serialization/deserialization tools for the IOF XML 3.0 data standard.
Requirements
- PHP 8.3+
Installation
composer require petrocki/iof-xml-php
Usage
Deserializing (XML → PHP objects)
use IofXmlPhp\Deserializer\IofXmlDeserializer; $deserializer = new IofXmlDeserializer(); $entryList = $deserializer->deserializeEntryList(file_get_contents('entry-list.xml')); echo $entryList->getEvent()->getName();
Serializing (PHP objects → XML)
use IofXmlPhp\Serializer\IofXmlSerializer; $serializer = new IofXmlSerializer(); $xml = $serializer->serializeEntryList($entryList);
Configuring message metadata
- IOF XML root message elements (for example
OrganisationList,EntryList, etc.) contain common metadata fields such as the IOF version, creation time, and creator. - The library provides an
IofMessageFactorythat creates message objects with these metadata fields automatically initialized.
use IofXmlPhp\Factory\IofMessageFactory; $factory = new IofMessageFactory(creator: 'My Application'); $organisationList = $factory->create(OrganisationList::class);
Development
Docker
Build image:
docker build -t iof-xml-php:current .
Use bash in the container:
docker run -it -v "$(pwd):/var/www/iof-xml-php" iof-xml-php:current bash
Regenerating model classes
The classes in src/Model/ and metadata in src/Metadata/ are auto-generated from resources/IOF.xsd. Do not edit them manually. To regenerate after an XSD change:
vendor/bin/xsd2php convert config/xsd2php.yaml resources/IOF.xsd
Running tests
composer phpunit
Code style
composer cs-check composer cs-fix
Related
- IOF XML 3.0 Data Standard — official IOF repository with the XSD schema and documentation
- IOF XML 3.0 for .NET / C# — official IOF client library with model classes and utilities
- IOF XML 3.0 for Java / Kotlin — community library with model classes and utilities
- IOF XML 3.0 classes and helpers for GO — community library with model classes and utilities