Package Data | |
---|---|
Maintainer Username: | jurosh |
Maintainer Contact: | mitchell@kooding.nl (Mitchell van Wijngaarden) |
Package Create Date: | 2015-06-27 |
Package Last Update: | 2015-06-27 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-15 15:00:20 |
Package Statistics | |
---|---|
Total Downloads: | 12 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
A forked implementation of laravel-doctrine that melts with Laravel 5.
As this is a forked version the documentation still applies to most of the package. Please read the original documentation and README before using this fork.
Fixes for Laravel 5 support
UserProvider
(and here and here)New Functionality
Begin by installing the package through Composer. Edit your project's composer.json
to require mitchellvanw/laravel-doctrine
.
"require": {
"mitchellvanw/laravel-doctrine": "dev-l5",
"doctrine/orm": "2.5.*@dev"
},
"repositories": [
{
"type": "git",
"url": "https://github.com/FoxxMD/laravel-doctrine.git"
}
]
Next use Composer to update your project from the the Terminal:
php composer.phar update
Caveats
At the moment Doctrine\ORM version 2.5 is still in beta. As a result the composer install may require you to change
the minimum-stability
in your composer.json
to dev
.
If you don't want to affect the stability of the rest of the packages, you can add the following property in your composer.json
:
"prefer-stable": true
Once the package has been installed you'll need to add the service provider. Open your app/config/app.php
configuration file, and add a new item to the providers
array.
'Mitch\LaravelDoctrine\LaravelDoctrineServiceProvider'
After This you'll need to add the facade. Open your app/config/app.php
configuration file, and add a new item to the aliases
array.
'EntityManager' => 'Mitch\LaravelDoctrine\EntityManagerFacade',
'RegistryManager' => 'Mitch\LaravelDoctrine\RegistryManagerFacade'
It's recommended to publish the package configuration.
php artisan config:publish mitchellvanw/laravel-doctrine --path=vendor/mitchellvanw/laravel-doctrine/config
##Using different metadata drivers
Doctrine provides several drivers that can be used to map table information to entity classes. For more information see sections 19, 20, and 21 of the doctrine reference guide.
A default doctrine config will use the annotation driver. This is the way laravel-doctrine works out of the box. If this is all you need you can continue to use the documentation provided by laravel-doctrine's wiki.
To use a different driver edit the metadata
property of the entity manager you want to use the driver with (in doctrine.config
)
'entity_managers' => [
'default' => [
...
'metadata' => [
'simple' => false,
'driver' => 'yaml', //xml or yaml or annotation (ANNOTATION IS DEFAULT)
'paths' => [
base_path('app/Models/mappings') //all base paths to mapping directories go here
],
'extension' => '.dcm.yml' //extension for mapping files if not using simple driver
],
],
]
Refer to the doctrine reference guide on how to set up each driver.
##Using multiple entity managers
If you use the regular EntityManager
facade you will receive the default
EM defined in your doctrine config.
To use multiple entity managers
RegistryManager
facade orManagerRegistry
into your controllerUsing the facade
use RegistryManager;
public function __construct()
{
parent::__construct();
$this->_em = RegistryManager::getManager('tracking'); //gets 'tracking' EM
$this->_em = RegistryManager::getManager(); //gets 'default' EM
$this->inventoryRepo = $this->_em->getRepository('app\Models\Inventory');
}
Using DI
public function __construct(ManagerRegistry $reg)
{
parent::__construct();
$this->_em = $reg->getManager('tracking'); //gets 'tracking' EM
$this->_em = $reg->getManager(); //gets 'default' EM
$this->inventoryRepo = $this->_em->getRepository('app\Models\Inventory');
}
DoctrineExtensions is a set of extensions to Doctrine 2 that add support for additional query functions available in MySQL and Oracle. To learn more about what additional functionality is added visit the package's github page.
To use DoctrineExtensions install the package with composer:
composer require beberlei/DoctrineExtensions
Configuring extensions is easy and follows the pattern used by DoctrineExtensions in its own config.
In your doctrine config simply add a dql
array to every entity manager you want extensions accessible from or add the array to the top-level of your configuration to have it applied to all entity managers.
'dql' => [
'numeric_functions' => [
'ROUND' => 'DoctrineExtensions\Query\Mysql\Round',
'POWER' => 'DoctrineExtensions\Query\Mysql\Power'
...
],
'string_functions' => [
'REPLACE' => 'DoctrineExtensions\Query\Mysql\Replace'
...
],
'datetime_functions' => [
'DATE' => 'DoctrineExtensions\Query\Mysql\Date'
...
]
]
That's it! Use DoctrineExtensions as you normally would.
A complete sample of doctrine configuration taking advantage of all new functionality, with comments.
return [
'default_connection' => 'default',
'entity_managers' => [
'default' => [ //MUST have an entity_managers entry for 'default'
'connection' => 'rdsConnection',
'cache_provider' => null,
'repository' => 'Doctrine\ORM\EntityRepository',
'logger' => null,
'metadata' => [
'simple' => false,
'driver' => 'yaml', //xml or yaml or annotation (ANNOTATION IS DEFAULT)
'paths' => [
base_path('app/Models/mappings') //all base paths to mapping directories go here
],
'extension' => '.dcm.yml' //extension for mapping files if not using simple driver
],
//Only usable if DoctrineExtensions is installed
/*'dql' => [
'numeric_functions' => [
'ROUND' => 'DoctrineExtensions\Query\Mysql\Round',
'POWER' => 'DoctrineExtensions\Query\Mysql\Power'
...
],
'string_functions' => [
'REPLACE' => 'DoctrineExtensions\Query\Mysql\Replace'
...
],
'datetime_functions' => [
'DATE' => 'DoctrineExtensions\Query\Mysql\Date'
...
]
]*/
],
'tracking' => [
'connection' => 'trackingConnection',
'cache_provider' => null,
'repository' => 'Doctrine\ORM\EntityRepository',
'simple_annotations' => false,
'logger' => null,
'metadata' => [
'simple' => false,
'driver' => 'annotation'
//paths is not necessary for annotation
],
],
],
'proxy' => [
'auto_generate' => true, //create proxy files automatically (turn off for production)
'directory' => base_path('storage/proxies'), //store them outside of default directory
'namespace' => null
],
//'cache_provider' => 'apc',
//'logger' => new \Doctrine\DBAL\Logging\EchoSQLLogger()
//'dql' => ...
];
#Issues and Contributing
If you have issues related to changes made in this forked version please open an issue on this repository.
If your issue is general or related to functionality that exists in the original repo please direct your questions there.
This fork is not an official implementation of laravel-doctrine for Laravel 5 so I cannot gaurantee that it will continue to work or or be maintained in the future as Laravel changes, HOWEVER I use it on a daily basis with production code and so will keep it up to date as long as it is relevant for me.
I am happy to accept PRs and any other contributions from the community and will respond in a timely manner. I am open to accepting collaborators as well.
This package is licensed under the MIT license.