xsd to php classes generator, wadl to php code generator(soon)
mkdir -p /path_to_project/project_name
cd /path_to_project/project_name
mkdir -p vendor
cd vendor
git clone https://github.com/servandserv/happymeal.git
cp /happymeal/happymeal.ini /path_to_project/project_name
- Configurate happymeal.ini file
- Run the bash script
path_to_happymeal/happymeal xsd2php path_to_project/project_name/happymeal.ini
- Include classes to project
- Use data classes
Read xml file and parser to object
$obj = new \namespace\Object();
if($xmlstr = file_get_contents('file_path')) {
$obj->fromXmlStr($xmlstr);
}
Translate object to xml str
$obj = new \namespace\Object();
$obj->setProp1("prop1");
$obj->setProp2("prop2");
$xmlstr = $obj->toXmlStr();
Validate object
use \com\servandserv\happymeal\ErrorsHandler;
$eh = new ErrorsHandler();
$obj = new \namespace\Object();
if($xmlstr = file_get_contents('file_path')) {
$obj->fromXmlStr($xmlstr);
}
if( $errors = $obj->validateType( $eh ) ) {
header( "Content-Type: application/xml" );
print $errors->toXmlStr();
exit;
}