1. Go to this page and download the library: Download ocramius/generated-hydrator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// classes for which we want to pre-generate the hydrators
$classes = [
\My\Namespace\ClassOne::class,
\My\Namespace\ClassTwo::class,
\My\Namespace\ClassThree::class,
];
foreach ($classes as $class) {
$config = new \GeneratedHydrator\Configuration($class);
$config->setGeneratedClassesTargetDir('/path/to/target-dir');
$config->createFactory()->getHydratorClass();
}
$config = new \GeneratedHydrator\Configuration(\My\Namespace\ClassOne::class);
spl_autoload_register($config->getGeneratedClassAutoloader());
// now simply use your hydrator, and if possible, code generation will be skipped:
$hydratorName = $config->createFactory()->getHydratorClass();
$hydrator = new $hydratorName();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.