Install DoctrineFixturesBundle with Symfony2

I am trying to install an existing Symfony 2.0 project and therefore I run rm -rf vendor and bin / vendor install. It cannot find the DoctrineFixturesBundle, so I update the deps file and add:

[DoctrineFixturesBundle] git=https://github.com/doctrine/DoctrineFixturesBundle.git target=/bundles/Symfony/Bundle/DoctrineFixturesBundle version=origin/2.0 

I run rm -rf vendor / * and bin / vendor install again and I get this error:

The autoloader expects the class "Symfony \ Bundle \ DoctrineFixturesBundle \ DoctrineFixturesBundle" to be defined in the file "/home/me/developpement/myproject/app/../vendor/bundles/Symfony/Bundle/DoctrineFixturesBundle/DoctrineFixturesBundle.p. The file was found, but the class was not in it, the class name or namespace probably has a typo.

So, in my AppKernel.php, I replace:

 new Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle(), 

with:

 new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(), 

because the file namespace DoctrineFixturesBundle.php is Doctrine \ Bundle \ FixturesBundle.

And now, I get this error:

Fatal error: class "Doctrine \ Bundle" / "Lamp") was not found in /home/me/developpement/myproject/app/AppKernel.php on line 21

What should I do to make it work?

Edited to add :

This is my autoload.php:

 $loader->registerNamespaces(array( 'Symfony' => array(__DIR__.'/../vendor/symfony/src', __DIR__.'/../vendor/bundles'), 'Sensio' => __DIR__.'/../vendor/bundles', 'JMS' => __DIR__.'/../vendor/bundles', 'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib', 'Doctrine\\DBAL' => __DIR__.'/../vendor/doctrine-dbal/lib', 'Doctrine' => __DIR__.'/../vendor/doctrine/lib', 'Monolog' => __DIR__.'/../vendor/monolog/src', 'Assetic' => __DIR__.'/../vendor/assetic/src', 'Metadata' => __DIR__.'/../vendor/metadata/src', 'Gedmo' => __DIR__.'/../vendor/gedmo-doctrine-extensions/lib', 'Doctrine\\Common\\DataFixtures' => __DIR__.'/../vendor/doctrine-fixtures/lib', 'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib', 'Doctrine\\DBAL\\Migrations' => __DIR__.'/../vendor/doctrine-migrations/lib', 'Doctrine\\DBAL' => __DIR__.'/../vendor/doctrine-dbal/lib', 'Knp\Component' => __DIR__.'/../vendor/knp-components/src', 'Knp\Bundle' => __DIR__.'/../vendor/bundles', )); 
+4
source share
2 answers

Have you checked your autoload.php? This is where you tell Symfony which namespace is in a particular directory.

+2
source

The namespace is probably not loading automatically. Check this vendor\composer\autoload_namespaces.php and make sure that it contains the following code.

'Doctrine\\Bundle\\FixturesBundle' => array($vendorDir . '/doctrine/doctrine-fixtures-bundle') ,

0
source

All Articles