Cannot autowire service: Argument references class but no such service exists

Starting from the 1.8 version of DoctrineBundle, you can extend your class using Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository instead of Doctrine\ORM\EntityRepository. The result will be the same, but this does support the autowire. Example: use App\Entity\Activation; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Common\Persistence\ManagerRegistry; class ActivationRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, Activation::class); } // … }

Symfony 2: INNER JOIN on non related table with doctrine query builder

Today I was working on similar task and remembered that I opened this issue. I don’t know since which doctrine version it’s working but right now you can easily join the child classes in inheritance mapping. So a query like this is working without any problem: $query = $this->createQueryBuilder(‘c’) ->select(‘c’) ->leftJoin(‘MyBundleName:ChildOne’, ‘co’, ‘WITH’, ‘co.id = … Read more

Symfony: Clear doctrine cache

For Symfony 3+: php bin/console will list all commands, the following are relevant for cache: php bin/console doctrine:cache:clear-metadata php bin/console doctrine:cache:clear-query php bin/console doctrine:cache:clear-result Before Symfony 3: app/console will list how you can do it app/console doctrine:cache:clear-metadata app/console doctrine:cache:clear-query app/console doctrine:cache:clear-result

Symfony2 Use Doctrine in Service Container

According to your code, you already have an EntityManager injected. You don’t need to call $em = $this->get(‘doctrine’)->getEntityManager() — just use $this->em. If you don’t inject an EntityManager already, read this. UPDATE: You need to make the container inject an EntityManager into your service. Here’s an example of doing it in config.yml: services: your.service: class: … Read more

PHPUnit Mock Objects and Static Methods

Sebastian Bergmann, the author of PHPUnit, recently had a blog post about Stubbing and Mocking Static Methods. With PHPUnit 3.5 and PHP 5.3 as well as consistent use of late static binding, you can do $class::staticExpects($this->any()) ->method(‘helper’) ->will($this->returnValue(‘bar’)); Update: staticExpects is deprecated as of PHPUnit 3.8 and will be removed completely with later versions.

Generating a single Entity from existing database using symfony2 and doctrine

I had the same problem, you’ve to do this way: php app/console doctrine:mapping:convert metadata_format \ ./src/App/MyBundle/Resources/config/doctrine \ –from-database \ –filter=”Yourtablename” Then php app/console doctrine:mapping:import AppMyBundle \ metadata_format –filter=”Yourtablename” Where metadata_format is the file ending you want to generate (e.g. xml, yml, annotation) And finally php app/console doctrine:generate:entities AppMyBundle –no-backup Like this doctrine will load only … Read more

Best way to create a test database and load fixtures on Symfony 2 WebTestCase?

If you want to use doctrine:fixtures:load, you can use the –append option to avoid the user confirmation. Since you are recreating the database every time, purging is unnecessary. I used to use doctrine fixtures alone for testing, but have since switched to using fixtures & LiipFunctionalTestBundle to avoid DRY. This bundle makes fixtures easier to … Read more

Symfony2: how to get all entities of one type which are marked with “EDIT” ACL permission?

I don’t believe there’s a default way of doing this. What you could do is to write your own service that adds a Filter to your Doctrine DQL queries. For more info, see: https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/filters.html https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/cookbook/dql-custom-walkers.html Hope this helps!

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)