-
Notifications
You must be signed in to change notification settings - Fork 44
Home
mikebevz edited this page Jan 7, 2011
·
36 revisions
Legko XML is a set of classes helping you to send/receive XML messages.
- Compile XML Schema files to PHP bindings
- XML Marshalling - save PHP classes as XML
- XML Unmarshalling - bind XML to PHP classes
- Generate WSDL - generate XSD aware WSDL (WSDL 1.1)
- PHP 5.3 or higher, due to heavy use of PHP namespaces
- XSL extension, libxslt 1.1.x - tested on 1.1.23
- LibXML extension, version 2.6.x, tested on 2.6.32
- DOM extension
- XPath Support enabled
- Schema Support enabled
/lib - 3rd party libraries
/resources - XML Schema files used for testing
/src - Source code
/com/mikebevz/xsd2php
/tools
/legko.php - Command line interface
/test - Unit tests
- Create XSD schema from PHP classes
- WSDL 2.0
use com\mikebevz\xsd2php;
$xsd2php = new xsd2php\Xsd2Php("path/to/schema.xsd");
$xsd2php->saveClasses("path/to/generated/files", true);
Second argument in saveClasses method defines whether create a directory if it doesn't exist. See test/Xsd2PhpTest.php for examples.
On example of UBL Order schema:
use com\mikebevz\xsd2php;
use oasis\names\specification\ubl\schema\xsd\Order_2;
$order = new Order_2\Order(); // Generated PHP model
// set $order properties here
$php2xml = new xsd2php\Php2Xml();
$xml = $php2xml->getXml($order);
use com\mikebevz\xsd2php;
$xml = file_get_contents('path/to/your.xml');
$model = new yourModel();
$bind = new xsd2php\Bind();
$myUnmarshalledModel = $bind->bindXml($xml, $model);
From command line
$ cd test
$ phpunit
will start all available tests.
http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/