olvlvl/doctrine-generators

Generators for Doctrine's hydrators and proxies.

v3.0.0 2019-10-03 06:41 UTC

This package is auto-updated.

Last update: 2024-10-29 05:40:29 UTC


README

Packagist Build Status Code Quality Code Coverage Downloads

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);

Requirements

The package requires PHP 7.2 or later.

Installation

The recommended way to install this package is through Composer:

$ composer require olvlvl/doctrine-generators

Testing

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.

Build Status Code Coverage

License

olvlvl/doctrine-generators is licensed under the New BSD License - See the LICENSE file for details.