harmbandstra / edexmllib
PHP Library for validating and importing Edexml files.
Installs: 2 522
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 1
Requires
- php: ^7.2 || ^8.0
- ext-dom: *
- ext-libxml: *
- goetas-webservices/xsd2php-runtime: ^0.2.16
Requires (Dev)
- goetas-webservices/xsd2php: ^0.4.6
- phpunit/phpunit: ^7.5
README
PHP Library for validating and importing Edexml files.
Installation
Install with composer:
$ composer require harmbandstra/edexmllib
Usage
$xml = file_get_contents('path_to_file'); try { $edex = EdexmlFactory::load($xml); } catch (ValidationException $exception) { // Handle exception } foreach ($edex->getGroepen()->getGroep() as $groep) { echo $groep->getNaam(); } foreach ($edex->getLeerlingen() as $leerling) { echo $leerling->getGebruikersnaam(); }
If the Edexml file contains elements with a type defined in a non-public XSD, you can strip the block before loading the XML.
$xml = file_get_contents('path_to_file'); try { $edex = EdexmlFactory::load( EdexmlFactory::stripToevoegingen($xml) ); } catch (ValidationException $exception) { // Handle exception }
To skip validation, set strict to false
$xml = file_get_contents('path_to_file'); $edex = EdexmlFactory::load($xml, false);
Development
The library uses xsd2php for creating JMS Serializer definition files. These files are used to deserialize the XML into bite-sized PHP objects.
Generate classes
To generate new classed and JMS Serializer configuration based on the XSD files, run:
php vendor/bin/xsd2php convert config.yml src/Resources/xsd/*.xsd
This is only needed when the specification changes.