PHP 致命错误:在第 25 行的 /va r/app/current/app/app/AppKernel.php 中找


PHP Fatal error: Class 'VichUploaderBundleVichUploaderBundle' not found in /va r/app/current/app/AppKernel.php on line 25

  $bundles = array(
        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 Symfony'Bundle'AsseticBundle'AsseticBundle(),
        new Doctrine'Bundle'DoctrineBundle'DoctrineBundle(),
        new Sensio'Bundle'FrameworkExtraBundle'SensioFrameworkExtraBundle(),
        new JMS'I18nRoutingBundle'JMSI18nRoutingBundle(),
        new JMS'TranslationBundle'JMSTranslationBundle(),
        new Doctrine'Bundle'FixturesBundle'DoctrineFixturesBundle(),
        new Maxmind'Bundle'GeoipBundle'MaxmindGeoipBundle(),
        new FOS'UserBundle'FOSUserBundle(),
        new Knp'Bundle'GaufretteBundle'KnpGaufretteBundle(),
        new Vich'UploaderBundle'VichUploaderBundle(),
        new JMS'DiExtraBundle'JMSDiExtraBundle($this),
        new JMS'AopBundle'JMSAopBundle(),
        new Knp'Bundle'SnappyBundle'KnpSnappyBundle(),
        new Sonata'IntlBundle'SonataIntlBundle(),
 );

请让我知道为什么会发生这种情况?....我们需要更新作曲家吗?

命名空间似乎有问题?

看起来这是一个作曲家问题,因为捆绑声明已经命名空间,我假设您还没有弄清楚 AppKernel 如何设置它的自动加载器。

您需要将库添加到作曲家:

composer require vich/uploader-bundle:0.14.0

或者,如果您手动更新了 composer.json,则需要运行:

composer update --lock

这将安装依赖项,更新锁定文件,并重新生成自动加载.php文件。这些命令可能会也可能不会起作用,具体取决于您安装编辑器的方式(可能需要在命令前面加上 php composer.phar 而不是 composer (。你需要自己弄清楚。此外,您还需要指定所需的版本。我只是从packagist选择了最新的马厩。