Silex auth system with ORM doctrine

I am working on an auth system in silex using doctrine orm, and in this document http://silex.sensiolabs.org/doc/providers/security.html#defining-a-custom-user-provider below the circuit there is information that sounds So:

"If you use Doctrine ORM, the Symfony bridge for Doctrine provides a user provider class that can load users from your objects."

I use the Dotrine ORM provider, so I decided to use the EntityUserProvider class for Symfony \ Bridge \ Doctrine \ Security \ User, and the problem is the constructor of this class, since the first argument is "registry manager registry".

What should I put there from Silex? Is there a dedicated service or object for this?

+4
source share
1 answer

In the context of Symfony2 and in accordance with the source code of Doctrine and Symfony Doctrine Bridge, you will need to enter a service called doctrine that takes connection , entity manager , default connection and default entity manager as arguments. This service is defined in vendor\{...}\Doctrine\Bundle\DoctrineBundle\Resources\config\dbal.xml .

(This service is an instance of Doctrine\Bundle\DoctrineBundle\Registry that extends the Abstract class Symfony\Bridge\Doctrine\ManagerRegistry , which extends Doctrine\Common\Persistence\AbstractManagerRegistry , which finally implements the Doctrine\Common\Persistence\ManagerRegistry , which is a type of intended class.)

As mentioned in the first few lines of the Silex vendor documentation according to Doctrine , the ORM service is not provided. Since you are using a custom provider to use ORM, you need to enter the equivalent of this doctrine service.

+1
source

All Articles