Skip to content

EvanCoh/xsd2php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xsd2php

Build Status Code Coverage Scrutinizer Code Quality

Convert XSD into PHP classes.

With goetas/xsd2php you can convert any XSD/WSDL definition into PHP classes.

XSD2PHP can also generate JMS Serializer compatible metadata that can be used to serialize/unserialize the object instances.

Installation

There are two recommended ways to install xsd2php via Composer:

  • adding the dependency to your composer.json file:
"require": {
    ..
    "goetas/xsd2php":"2.*@dev",
    "goetas/xsd-reader":"2.*@dev",
    ..
}

Usage

With this example we will convert OTA XSD definitions into PHP classes.

Suppose that you have allo XSD files in /home/my/ota.

Generate PHP classes

bin/xsd2php.php convert:php \
`/home/my/ota/OTA_HotelAvail*.xsd \

--ns-map='http://www.opentravel.org/OTA/2003/05; Mercurio/OTA/2007B/' \

--ns-dest='Mercurio/OTA/2007B/; src/Mercurio/OTA/V2007B;' \

--alias-map='Vendor/Project/CustomDateClass; http://www.opentravel.org/OTA/2003/05#CustomOTADateTimeFormat'

What about namespaces?

  • http://www.opentravel.org/OTA/2003/05 will be converted into Mercurio/OTA/2007B PHP namespace

Where place the files?

  • Mercurio/OTA/2007B classes will be placed into src/Mercurio/OTA/V2007B directory

What about custom types?

  • --alias-map='Vendor/Project/CustomDateClass;http://www.opentravel.org/OTA/2003/05#CustomOTADateTimeFormat' will instcut XSD2PHP to do not generate any class for CustomOTADateTimeFormat type inside http://www.opentravel.org/OTA/2003/05 namesapce. All reference to this type are replaced with the Vendor/Project/CustomDateClass class.

Serilize / Unserialize

XSD2PHP can also generate for you JMS Serializer metadata that you can use to serialize/unserialize the generated PHP class instances.

bin/xsd2php.php  convert:jms-yaml \
`/home/my/ota/OTA_HotelAvail*.xsd \

--ns-map='http://www.opentravel.org/OTA/2003/05;Mercurio/OTA/2007B/'  \
--ns-dest='Mercurio/OTA/2007B/;src/Metadata/JMS;' \

--alias-map='http://www.opentravel.org/OTA/2003/05#CustomOTADateTimeFormat;Vendor/Project/CustomDateClass'

What about namespaces?

  • http://www.opentravel.org/OTA/2003/05 will be converted into Mercurio/OTA/2007B PHP namespace

Where place the files?

  • http://www.opentravel.org/OTA/2003/05 will be placed into src/Metadata/JMS directory

What about custom types?

  • --alias-map='Vendor/Project/CustomDateClass;http://www.opentravel.org/OTA/2003/05#CustomOTADateTimeFormat' will instcut XSD2PHP to do not generate any metadata infmation for CustomOTADateTimeFormat type inside http://www.opentravel.org/OTA/2003/05 namesapce. All reference to this type are replaced with the Vendor/Project/CustomDateClass class. You have to provide a custom serializer for this type

About

Convert XSD into PHP classes

Resources

Stars

Watchers

Forks

Packages

No packages published