Download the PHP package radnan/rdn-doctrine without Composer
On this page you can find all versions of the php package radnan/rdn-doctrine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package rdn-doctrine
RdnDoctrine
The RdnDoctrine ZF2 module is a simple bridge to the Doctrine ORM library.
How to install
-
Use
composer
to require theradnan/rdn-doctrine
package:$ composer require radnan/rdn-doctrine:1.*
-
Activate the module by including it in your
application.config.php
file:
In order to access an entity repository we call the same entity($name)
plugin, only this time we provide an entity name:
namespace App\Controller;
use App\Entity;
class User
{
public function editAction()
{
$id = $this->params('user-id');
$user = $this->entity('User')->find($id);
/**
* Alternatively we can be more explicit and request the
* User entity within the App module
*/
$user = $this->entity('App:User')->find($id);
}
}
The RdnDoctrine\EntityManager\AliasResolver
service is used to resolve aliases when one is not provided. For example, if User
is given instead of App:User
.
Code completion
If you'd like to have code completion for this plugin, include the following in your AbstractController
class:
namespace App\Controller;
use Zend\Mvc\Controller\AbstractActionController;
/**
* @method \Doctrine\ORM\EntityRepository|\Doctrine\ORM\EntityManager entity(\string $name = null) Get the entity manager or a repository for given entity name.
*/
abstract class AbstractController extends AbstractActionController
{
}
Then, simply extend your controllers off of this abstract controller.
Console commands
The module also comes with a set of console commands to manage the database schema and generate proxies.
You can run vendor/bin/console
to run and get help on the console commands in the doctrine:
namespace.
Shared entities
Usually you will have one module that will contain all your common entities such as User entities etc. You will also register a single entity manager for your application with the same name as this module.
You will then create separate modules for each section of your site. Each module will depend on the entities provided by the common module in addition to providing its own. But all of the modules will use the single shared entity manager.
Let's say our common module is called App and we have another module called Foo. In this case the configuration for the Foo module would look like this:
All versions of rdn-doctrine with dependencies
radnan/rdn-console Version 1.*
radnan/rdn-database Version 1.*
radnan/rdn-factory Version 1.*
zendframework/zend-mvc Version 2.*
zendframework/zend-servicemanager Version 2.*