Symfony2 Use Doctrine in Service Container

后端 未结 8 515
猫巷女王i
猫巷女王i 2020-12-08 12:59

How do I use Doctrine in a service container?

The Code just causes an error message \"Fatal error: Call to undefined method ...::get()\".



        
8条回答
  •  难免孤独
    2020-12-08 13:28

    I am using Symfony 3.4. If you want to create a service in a bundle this works for me:

    services:
     Vendor\YourBundle\Service\YourService:
       arguments:
         $em: '@doctrine.orm.entity_manager'
    

    In your Service.php

    em = $em;
     }
    
    }
    

提交回复
热议问题