Symfony - ClassNotFoundException:尝试加载类" DoctrineMigrationsBundle"

时间:2017-11-26 17:50:02

标签: php symfony

我正在尝试使用Symfony文档安装DoctrineMigrationsBundle。我配置了AppKernel和config.yml,当我尝试运行命令时:" php app / console doctrine:migrations:status"显示此错误:

1970-01-01T00:00:00Z

AppKernel:

    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

<?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'); } } 知道如何解决这个问题。你能救我吗?

1 个答案:

答案 0 :(得分:0)

试试composer dump-autoload。然后再次运行命令。