Skip to content

Latest commit

 

History

History
100 lines (66 loc) · 2.87 KB

install.rst

File metadata and controls

100 lines (66 loc) · 2.87 KB

Install

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

Environment variables used inside the config

  • DOCTRINE_METADATA - The type of metadata for the Doctrine entities. Defaults to attributes.
  • DOCTRINE_PROXY_AUTOGENERATE - Whether to autogenerate proxies. Should be set to false for production.
  • DOCTRINE_CACHE - The cache handler. Default is array.
  • DOCTRINE_METADATA_CACHE - The cache handler for metadata. Default is DOCTRINE_CACHE.
  • DOCTRINE_QUERY_CACHE - The cache handler for the query cache. Default is DOCTRINE_CACHE.
  • DOCTRINE_RESULT_CACHE - The cache handler for the results. Default is DOCTRINE_CACHE.
  • DOCTRINE_LOGGER - The logger to use to log DQL queries.

Application Folder Structure

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.

Entity Metadata

Change the config/doctrine.php file paths

'paths' => [
    base_path('app/Doctrine/ORM/Entity'),
],

Manual Registration

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