简体   繁体   English

Symfony错误:找不到类'Symfony \\ Component \\ HttpKernel \\ Kernel'

[英]Symfony error: Class 'Symfony\Component\HttpKernel\Kernel' not found

After upgrading from Symfony 3.1 to 3.2 I get this error message : 从Symfony 3.1升级到3.2后,我收到以下错误消息:

Fatal error: Class 'Symfony\\Component\\HttpKernel\\Kernel' not found in /var/www/html/HeliosBlog/app/AppKernel.php on line 6 致命错误:第6行的/var/www/html/HeliosBlog/app/AppKernel.php中找不到类'Symfony \\ Component \\ HttpKernel \\ Kernel'

Here's what my app/autoload.php looks like: 这是我的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;

Here's what my app_dev.php file looks like: 这是我的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);

And here's what my AppKernel.php looks like: 这就是我的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');
    }
}

Already tried removing the vendor folder and doing a composer install. 已经尝试删除供应商文件夹并进行作曲家安装。

Any ideas? 有任何想法吗?

I was able to solve it by simply adding 我只需添加即可解决问题

require_once __DIR__.'/autoload.php';

to app/console before 到应用程序/控制台之前

require_once __DIR__ . '/AppKernel.php';` 

Ran into the same error. 陷入同样的​​错误。 Found that the bootstrap.php.cache was unaware of the Kernel class. 发现bootstrap.php.cache没有意识到内核类。 This happened due the Sensio Distibution bundle having an update. 这是因为Sensio Distibution捆绑包有更新。 For this I posted an issue which can be found here: https://github.com/sensiolabs/SensioDistributionBundle/issues/302 为此,我发布了一个问题,可以在这里找到: https//github.com/sensiolabs/SensioDistributionBundle/issues/302

I hope this helps others as well. 我希望这对其他人也有帮助。

I had this issue while running composer update, because it was still using app/console (probably outdated) instead of the new bin/console . 我在运行composer update时遇到了这个问题,因为它仍然使用app/console (可能已过时)而不是新的bin/console

I fixed this issue by: 我解决了这个问题:

  • removing app/console file. 删除app/console文件。
  • creating a var/ folder in my project root directory - see this answer for explanation. 在我的项目根目录中创建一个var/文件夹 - 请参阅此答案以获得解释。

I run into this problem as well while updating my project from Symfony 2.x (can't remember whether it was 2.7 or 2.8) to 3.2. 我也遇到了这个问题,同时将我的项目从Symfony 2.x更新(不记得是2.7还是2.8)到3.2。 In turn out that the problem was caused by the app/console file. 结果是问题是由app/console文件引起的。 I believe the problem is caused by the way I created the project ages ago. 我认为问题是由我很久以前创建项目的方式引起的。

To solve this problem, I copied the app/console file from another project which I successfully upgraded to 3.2. 为了解决这个问题,我从另一个成功升级到3.2的项目中复制了app/console文件。 I am not sure whether there will be some other problems down the line, but at least I got rid of this error. 我不确定是否会有其他问题,但至少我摆脱了这个错误。

The discussion that prompted me to make this change is https://github.com/symfony/symfony/issues/16713 促使我做出这一改变的讨论是https://github.com/symfony/symfony/issues/16713

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到接口&#39;Symfony \\ Component \\ HttpKernel \\ HttpKernelInterface&#39; - Interface 'Symfony\Component\HttpKernel\HttpKernelInterface' not found Symfony \\ Component \\ HttpKernel \\ Exception \\ NotFoundHttpException:找不到对象 - Symfony\Component\HttpKernel\Exception\NotFoundHttpException: object not found Laravel 4错误Symfony \\组件\\ HttpKernel \\异常\\ NotFoundHttpException - Laravel 4 Error Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException Laravel错误Symfony \\ Component \\ HttpKernel \\ Exception \\ NotFoundHttpException - Laravel error Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException Laravel中的Symfony \\ Component \\ HttpKernel \\ Exception \\ NotFoundHttpException错误 - Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException Error in Laravel Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException laravel 8 错误 - Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException laravel 8 error Laravel “Symfony\Component\HttpKernel\Exception\HttpException”错误 - Laravel "Symfony\Component\HttpKernel\Exception\HttpException" error Laravel 错误 8 Symfony\Component\HttpKernel\Exception\NotFoundHttpException - Laravel error 8 Symfony\Component\HttpKernel\Exception\NotFoundHttpException request.ERROR: Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException: 没有找到“GET /”的路由 - request.ERROR: Symfony\Component\HttpKernel\Exception\NotFoundHttpException: No route found for “GET /” Symfony\Component\HttpKernel\Exception\NotFoundHttpException - Symfony\Component\HttpKernel\Exception\NotFoundHttpException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM