use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Cache\ArrayCache; use Hitch\HitchManager; use Hitch\Mapping\ClassMetadataFactory; use Hitch\Mapping\Loader\AnnotationLoader; // include the demo class loader include 'ClassLoader.php'; // set path to doctrine-common lib $DOCTRINE_COMMON_LIB = __DIR__ . '/../vendor/doctrine-common/lib'; // make sure doctrine-common exists if (!is_dir($DOCTRINE_COMMON_LIB)) { die('<span style="color: red;">Make sure to download and install the doctrine-common (<a href="https://github.com/doctrine/common">https://github.com/doctrine/common</a>) library to: ' . $DOCTRINE_COMMON_LIB . ' !!!</span>'); } // register namespaces for demo $loader = new ClassLoader(); $loader->registerNamespaces(array('Hitch' => __DIR__ . '/../lib', 'Hitch\\Demo' => __DIR__ . '/src', 'Doctrine\\Common' => $DOCTRINE_COMMON_LIB)); // register the autoloading $loader->register(); // create our new HitchManager $hitch = new HitchManager(); $hitch->setClassMetaDataFactory(new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()), new ArrayCache())); // pre-build the class meta data cache $hitch->registerRootClass('Hitch\\Demo\\Entity\\Catalog'); $hitch->buildClassMetaDatas(); // load XML file to parse $xml = file_get_contents("demo.xml"); // parse the xml into a Catalog object $catalog = $hitch->unmarshall($xml, 'Hitch\\Demo\\Entity\\Catalog'); // print general information echo "Version: " . $catalog->getMeta()->getVersion() . "<br />"; echo "Category: " . $catalog->getMeta()->getCategory() . "<br />";
<?php /** * @file * Load php-taxcloud library. */ if (!class_exists('ClassLoader')) { require_once __DIR__ . '/Autoload.php'; } $classLoader = new ClassLoader(); $classLoader->registerNamespaces(array('TaxCloud' => array(__DIR__, __DIR__ . '/../tests'))); $classLoader->register();