Installation of this module uses composer. For composer documentation, please refer to getcomposer.org
$ composer require laravel-doctrine/orm
To publish the config use:
php artisan vendor:publish --tag="config" --provider="LaravelDoctrine\ORM\DoctrineServiceProvider"
Thanks to Laravel auto package discovery, the ServiceProvider and Facades are automatically registered. However they can still be manually registered if required (see below).
Environment variables used inside the config
DOCTRINE_METADATA
- The type of metadata for the Doctrine entities. Defaults toattributes
.DOCTRINE_PROXY_AUTOGENERATE
- Whether to autogenerate proxies. Should be set tofalse
for production.DOCTRINE_CACHE
- The cache handler. Default isarray
.DOCTRINE_METADATA_CACHE
- The cache handler for metadata. Default isDOCTRINE_CACHE
.DOCTRINE_QUERY_CACHE
- The cache handler for the query cache. Default isDOCTRINE_CACHE
.DOCTRINE_RESULT_CACHE
- The cache handler for the results. Default isDOCTRINE_CACHE
.DOCTRINE_LOGGER
- The logger to use to log DQL queries.
Doctrine entities do not belong in the Model
directory. Doctrine supplies
not just an ORM but also an ODM.
So, when using Doctrine ORM, it is important to always address it as ORM.
This is the recommended directory structure for a Doctrine ORM Installation:
~/app/Doctrine/ORM
Underneath this directory you may choose to have one directory per entity manager or, for an app with just one entity manager, the following directories are suggested:
~/app/Doctrine/ORM/Entity
~/app/Doctrine/ORM/Repository
~/app/Doctrine/ORM/Subscriber
~/app/Doctrine/ORM/Listener
If you are new to Doctrine ORM, it is recommended you review the Repository Pattern.
Change the config/doctrine.php
file paths
'paths' => [
base_path('app/Doctrine/ORM/Entity'),
],
After updating composer, add the ServiceProvider to the providers
array in config/app.php
Optionally, you can register the EntityManager, Registry and/or Doctrine facades