Download the PHP package juliangut/doctrine-manager-builder without Composer
On this page you can find all versions of the php package juliangut/doctrine-manager-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download juliangut/doctrine-manager-builder
More information about juliangut/doctrine-manager-builder
Files in juliangut/doctrine-manager-builder
Package doctrine-manager-builder
Short Description Doctrine2 managers builder
License BSD-3-Clause
Homepage https://github.com/juliangut/doctrine-manager-builder
Informations about the package doctrine-manager-builder
Doctrine2 managers builder
Frees you from the tedious work of configuring Doctrine's managers, ORM Entity Manager, MongoDB Document Manager and CouchDB Document Manager.
Installation
Composer
If using MongoDB on PHP >= 7.0
Usage
Relational Database Entity Manager
MongoDB Document Manager
CouchDB Document Manager
Mind that Doctrine CouchDB ODM support is not as good/wide as in Doctrine ORM or Doctrine MongoDB ODM
Configuration
Common
metadata_mappingREQUIRED array of metadata mapping drivers or configurations to create them, see note belowannotation_filesarray of Doctrine annotations filesannotation_namespacesarray of Doctrine annotations namespacesannotation_autoloadersarray of Doctrine annotations auto-loader callableproxies_pathpath were Doctrine creates its proxy classes, defaults to /tmpproxies_namespacestring for proxies namespaceproxies_auto_generationinteger indicating proxy auto generation behaviormetadata_cache_driver\Doctrine\Common\Cache\CacheProvider metadata cache drivermetadata_cache_namespacestring for metadata cache namespace (different for each type of manager)event_managera configuredDoctrine\Common\EventManagerevent_subscribersan array of customDoctrine\Common\EventSubscriber
Relational ORM Entity Manager
connectionREQUIRED array of PDO configurations or a \Doctrine\DBAL\Connection. See supported driversquery_cache_driver\Doctrine\Common\Cache\CacheProvider query cache driver, defaults tometadata_cache_driverquery_cache_namespacestring for query cache namespace, defaults to 'DoctrineRDBMSORMQueryCache'result_cache_driver\Doctrine\Common\Cache\CacheProvider result cache driver, defaults tometadata_cache_driverresult_cache_namespacestring for result cache namespace, defaults to 'DoctrineRDBMSORMResultCache'hydrator_cache_driver\Doctrine\Common\Cache\CacheProvider hydrator cache driver, defaults tometadata_cache_driverhydrator_cache_namespacestring for hydrator cache namespace, defaults to 'DoctrineRDBMSORMHydratorCache'repository_factory\Doctrine\ORM\Repository\RepositoryFactorydefault_repository_class\Doctrine\ORM\EntityRepositorynaming_strategya\Doctrine\ORM\Mapping\NamingStrategy, defaults toUnderscoreNamingStrategyquote_strategya\Doctrine\ORM\Mapping\QuoteStrategy, defaults toDefaultQuoteStrategysecond_level_cache_configurationa\Doctrine\ORM\Cache\CacheConfigurationsql_loggera\Doctrine\DBAL\Logging\SQLLoggercustom_typesarray of'type_name' => '\Doctrine\DBAL\Types\Type'custom_mapping_typesarray of'type_name' => 'Doctrine type: a constant on \Doctrine\DBAL\Types\Type'. Used in conjunction with custom_typescustom_filtersarray of custom'filter_name' => '\Doctrine\ORM\Query\Filter\SQLFilter'string_functionsarray of custom'function_name' => '\Doctrine\ORM\Query\AST\Functions\FunctionNode'for string DQL functionsnumeric_functionsarray of custom'function_name' => '\Doctrine\ORM\Query\AST\Functions\FunctionNode'for numeric DQL functionsdatetime_functionsarray of custom'function_name' => '\Doctrine\ORM\Query\AST\Functions\FunctionNode'for datetime DQL functions
MongoDB ODM Document Manager
connectionREQUIRED array of \MongoClient configurations (server and options) or a \Doctrine\MongoDB\Connectiondefault_databaseREQUIRED default database to be used in case none specifiedhydrators_pathpath where Doctrine creates its hydrator classes, defaults to /tmphydrators_namespacestring for hydrators namespace, defaults to 'DoctrineMongoDBODMHydrator'hydrators_auto_generationinteger indicating hydrators auto generation behaviorpersistent_collections_pathpath where Doctrine creates its persistent collection classes, defaults to /tmppersistent_collections_namespacestring for persistent collections namespace, defaults to 'DoctrineMongoDBODMPersistentCollection'persistent_collections_auto_generationinteger persistent collections auto generation behaviorrepository_factory\Doctrine\ODM\MongoDB\Repository\RepositoryFactorydefault_repository_class\Doctrine\ODM\MongoDB\DocumentRepositorylogger_callablevalid callablecustom_typesarray of'type_name' => '\Doctrine\ODM\MongoDB\Types\Type'custom_filtersarray of custom'filter_name' => '\Doctrine\ODM\MongoDB\Query\Filter\BsonFilter'
CouchDB ODM Document Manager
connectionREQUIRED array of \Doctrine\CouchDB\CouchDBClient configurations or a \Doctrine\CouchDB\CouchDBClientrepository_factory\Jgut\Doctrine\ManagerBuilder\CouchDB\Repository\RepositoryFactorydefault_repository_class\Doctrine\ODM\CouchDB\DocumentRepositorylucene_handler_nameApache Lucene handler name
Considerations
- Make sure you always provide an
annotation_autoloadercallable to fallback in loading annotations, typically it will be 'class_exists'. If creating various managers this should be added to the last one generated. metadata_mappingmust be an array containing arrays of configurations to create MappingDriver objects:typeone of \Jgut\Doctrine\ManagerBuilder\ManagerBuilder constants:METADATA_MAPPING_ANNOTATION,METADATA_MAPPING_XML,METADATA_MAPPING_YAMLorMETADATA_MAPPING_PHPREQUIRED if no driverpatha string path or array of paths to where mapping files are REQUIRED if no driverextensionoverrides default mapping file extension: '.dcm.xml' for XML files and '.dcm.yml' for YAML filesnamespacethe namespace under which the mapped classes are REQUIRED only if more than ONE mapping driver is defineddriveran already created \Doctrine\Common\Persistence\Mapping\Driver\MappingDriver object REQUIRED if no type AND path
metadata_cache_driver, if not provided, is automatically generated in the following order based on availability:ApcuCache,XcacheCache,MemcacheCache,RedisCacheand finally fallback toArrayCachewhich is always available. Any other cache driver not provided will fallback to using a clone of metadata cache driver.proxies_auto_generation,hydrators_auto_generationandpersistent_collections_auto_generationconfiguration values are Doctrine\Common\Proxy\AbstractProxyFactory constants, in all cases it defaults toAUTOGENERATE_NEVER.
Managers are being configured ready for production, this means proxies, hydrators and persisten collections won't be automatically generated and, in case no cache driver is provided, one will be auto-generated. It is recommended you always provide your cache provider. For development you should use VoidCache.
Extending managers
Extending default managers with extra features is extremely easy. Lets see two examples with well-known libraries.
Adding new types
Using ramsey/uuid-doctrine
Adding new behaviour
Using gedmo/doctrine-extensions
Console integration
Although Doctrine ORM comes with a great CLI tool this library is intended to be used without ORM, and thus a new tool has been created instead of forcing to require Doctrine ORM.
This new CLI tool (doctrine-manager) is more powerful in the sense that it runs the same commands for different databases (managers) of the same kind by providing \Jgut\Doctrine\ManagerBuilder\ConsoleBuilder with named builders.
The configuration of doctrine-manager tool resembles the one ORM comes with and so you must have a 'cli-config.php' or ' config/cli-config.php' file
The only difference is that here you must return an instance of Symfony\Component\Console\Application instead of a Symfony\Component\Console\Helper\HelperSet
If you run ./vendor/bin/doctrine-manager list you will find the commands prefixed with builder's name, so commands are run with different managers
doctrine-manager only allows named manager builders
Contributing
Found a bug or have a feature request? Please open a new issue. Have a look at existing issues before.
See file CONTRIBUTING.md
License
See file LICENSE included with the source code for a copy of the license terms.