xampo
xampo

Reputation: 399

Symfony - ClassNotFoundException: Attempted to load class "DoctrineMigrationsBundle"

I`m trying to install DoctrineMigrationsBundle with Symfony Documentation. I configured AppKernel and config.yml and when I trying run a command: "php app/console doctrine:migrations:status" this error is displayed:

    PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "DoctrineMigrationsBundle" from namespace "Doctrine\Bundle\MigrationsBundle".
Did you forget a "use" statement for another namespace? in /home/xxx/project/app/AppKernel.php:17
Stack trace:
#0 /home/xxx/project/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(448): AppKernel->registerBundles()
#1 /home/xxx/project/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(114): Symfony\Component\HttpKernel\Kernel->initializeBundles()
#2 /home/xxx/project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(59): Symfony\Component\HttpKernel\Kernel->boot()
#3 /home/xxx/project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(122): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /home/xxx/project/bin/console(27): Symfony\Component\C in /home/xxx/project/app/AppKernel.php on line 17

AppKernel:

    <?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new AppBundle\AppBundle(),
        ];

        if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
            $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();

            if ('dev' === $this->getEnvironment()) {
                $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
                $bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
            }
        }

        return $bundles;
    }

    public function getRootDir()
    {
        return __DIR__;
    }

    public function getCacheDir()
    {
        return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
    }

    public function getLogDir()
    {
        return dirname(__DIR__).'/var/logs';
    }

    public function registerContainerConfiguration(LoaderInterface $loader)
    {
        $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
    }
}

Im really new in PHP&Symfony and I dont know much how to solve this problem. Can you help me?

Upvotes: 3

Views: 6450

Answers (1)

Łukasz D. Tulikowski
Łukasz D. Tulikowski

Reputation: 1495

Try composer dump-autoload. And run the command again.

Upvotes: 4

Related Questions