Installation in Laravel 6+
Install this package with composer:
composer require laravel-doctrine/orm doctrine/inflector:"^1.4|^2.0"
Thanks to Laravel auto package discovery feature, the ServiceProvider and Facades are automatically registered.
However they can still be manually registered if required
After updating composer, add the ServiceProvider to the providers array in
Optionally you can register the EntityManager, Registry and/or Doctrine facade:
'EntityManager' => LaravelDoctrine\ORM\Facades\EntityManager::class, 'Registry' => LaravelDoctrine\ORM\Facades\Registry::class, 'Doctrine' => LaravelDoctrine\ORM\Facades\Doctrine::class,
To publish the config use:
php artisan vendor:publish --tag="config" --provider="LaravelDoctrine\ORM\DoctrineServiceProvider"
Available environment variables inside the config are:
Important: By default, Laravel's application skeleton has its
Modelclasses in the
app/Modelsfolder. With Doctrine, you'll need to create a dedicated folder for your
Entitiesand point your
pathsarray to it. If you don't, Doctrine will scan your whole
app/folder for files, which will have a huge impact on performance!
'paths' => [ base_path('app/Entities'), ],