从Symfony 3.1升级到3.2后,出现此错误消息:
致命错误:Class' Symfony \ Component \ HttpKernel \ Kernel'不 在第6行的/var/www/html/HeliosBlog/app/AppKernel.php中找到
这是我的app / autoload.php的样子:
<?php
use Doctrine\Common\Annotations\AnnotationRegistry;
if (!$loader = @include __DIR__.'/../vendor/autoload.php') {
$message = <<< EOF
EOF;
if (PHP_SAPI === 'cli') {
$message = strip_tags($message);
}
die($message);
}
// intl
if (!function_exists('intl_get_error_code')) {
require_once __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php';
$loader->add('', __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs');
}
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
return $loader;
这是我的app_dev.php文件的样子:
<?php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(@$_SERVER['REMOTE_ADDR'], array(
'127.0.0.1',
'fe80::1', '::1')) || php_sapi_name() === 'cli-server')
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
$loader = require __DIR__.'/../app/autoload.php';
Debug::enable();
require_once __DIR__.'/../app/AppKernel.php';
$kernel = new AppKernel('dev', true);
//$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
这就是我的AppKernel.php的样子:
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$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 Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new JMS\AopBundle\JMSAopBundle(),
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(),
new Helios\BlogBundle\HeliosBlogBundle(),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new Helios\UserBundle\HeliosUserBundle(),
new FOS\UserBundle\FOSUserBundle(),
new FOS\ElasticaBundle\FOSElasticaBundle(),
new Knp\Bundle\MarkdownBundle\KnpMarkdownBundle(),
new Helios\ManagerBundle\HeliosManagerBundle(),
new FOS\JsRoutingBundle\FOSJsRoutingBundle(),
//new Avalanche\Bundle\ImagineBundle\AvalancheImagineBundle(),
new Oneup\UploaderBundle\OneupUploaderBundle(),
new Gregwar\CaptchaBundle\GregwarCaptchaBundle(),
new Sonata\AdminBundle\SonataAdminBundle(),
new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),
new Sonata\CoreBundle\SonataCoreBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
new HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
new Ivory\CKEditorBundle\IvoryCKEditorBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
$bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle();
$bundles[] = new CoreSphere\ConsoleBundle\CoreSphereConsoleBundle();
}
return $bundles;
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
}
}
已经尝试删除供应商文件夹并进行作曲家安装。
有什么想法吗?
答案 0 :(得分:4)
遇到同样的错误。发现bootstrap.php.cache没有意识到内核类。 这是因为Sensio Distibution捆绑包有更新。 为此,我发布了一个问题,可以在这里找到: https://github.com/sensiolabs/SensioDistributionBundle/issues/302
我希望这对其他人也有帮助。
答案 1 :(得分:3)
我在运行composer update时遇到了这个问题,因为它仍在使用app/console
(可能已过时)而不是新的bin/console
。
我通过以下方式解决了这个问题:
app/console
文件。var/
文件夹 - 有关说明,请参阅this answer。答案 2 :(得分:2)
我也遇到了这个问题,同时将我的项目从Symfony 2.x更新(无法记住它是2.7还是2.8)到3.2。反过来说问题是由app/console
文件引起的。我认为问题是由我很久以前创建项目的方式引起的。
为了解决这个问题,我将app/console
文件从我成功升级到3.2的另一个项目中复制了。我不确定是否会有其他问题,但至少我摆脱了这个错误。
促使我进行此更改的讨论是https://github.com/symfony/symfony/issues/16713