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

时间:2014-01-19 01:03:42

标签: symfony

希望其他人遇到这个问题。刚刚下载了一个Symfony项目,我收到上面的错误消息:“PHP致命错误:第7行/Applications/MAMP/htdocs/myapp/app/AppKernel.php中找不到类'Symfony \ Component \ HttpKernel \ Kernel'

我是设置Symfony的新手,这就是我的app / autoload.php的样子:

<?php

use Doctrine\Common\Annotations\AnnotationRegistry;

$loader = require __DIR__.'/../vendor/autoload.php';


// intl
if (!function_exists('intl_get_error_code')) {
    require_once __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php';
}

AnnotationRegistry::registerLoader(array($loader, 'loadClass'));

return $loader;

以下是我的app_dev.php文件的样子:

#!/usr/bin/env php
<?php

// if you don't want to setup permissions the proper way, just uncomment the following  PHP line
 // read http://symfony.com/doc/current/book/installation.html#configuration-and-setup   for more information
umask(0000);

set_time_limit(0);

require_once __DIR__.'/bootstrap.php.cache';
require_once __DIR__.'/AppKernel.php';

use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;

$input = new ArgvInput();
$env = $input->getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev');
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';

$kernel = new AppKernel($env, $debug);
$application = new Application($kernel);
$application->run($input);

如果有人能指出我正确的方向,那将非常感谢!

3 个答案:

答案 0 :(得分:3)

请尝试。

composer install

有时它可能就这么简单。

答案 1 :(得分:0)

尝试添加

$kernel = new AppKernel($env, $debug);
$kernel->loadClassCache();
$application = new Application($kernel);
$application->run($input);

答案 2 :(得分:0)

谢谢你们的帮助。事实证明我已经搞砸了我的Apache安装,所以它没有找到intl扩展。一旦我再次安装,一切都很顺利。