olvlvl/doctrine-generators provides generators for Doctrine's hydrators and proxies.
You can use these generators to create the hydrators and proxies required by your application before building its artifact or container image, so it's ready to be used as soon as it's deployed.
Disclaimer: Only MongoDB documents are currently supported.
<?php
use Doctrine\ODM\MongoDB\Configuration;
use olvlvl\DoctrineGenerators\Document\HydratorGenerator;
use olvlvl\DoctrineGenerators\Document\ProxyGenerator;
/* @var string $cacheDir */
// An excerpt of the configuration used to create the document manager
$config = new Configuration();
$config->setProxyDir("$cacheDir/Proxies");
$config->setProxyNamespace('Proxies');
$config->setAutoGenerateProxyClasses(Configuration::AUTOGENERATE_NEVER);
$config->setHydratorDir("$cacheDir/Hydrators");
$config->setHydratorNamespace('Hydrators');
$config->setAutoGenerateHydratorClasses(Configuration::AUTOGENERATE_NEVER);
/* @var \Doctrine\ODM\MongoDB\DocumentManager $dm */
$classes = (new HydratorGenerator)($dm);
$classes = (new ProxyGenerator)($dm);
The package requires PHP 7.2 or later.
The recommended way to install this package is through Composer:
$ composer require olvlvl/doctrine-generators
A container is available for local development. Enter the command make test-container
to start the
container and open a shell. The command make test
runs the test suite. Alternatively the command
make test-coverage
runs the test suite and also creates an HTML coverage report in
build/coverage
. Dependencies are installed as required.
The package is continuously tested by Travis CI.
olvlvl/doctrine-generators is licensed under the New BSD License - See the LICENSE file for details.