2
votes

Hopefully someone else has run into this problem. Just downloaded a Symfony project and I'm getting the above error message : "PHP Fatal error: Class 'Symfony\Component\HttpKernel\Kernel' not found in /Applications/MAMP/htdocs/myapp/app/AppKernel.php on line 7

I'm fairly new to setting up Symfony and here's what my app/autoload.php looks like:

<?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;

And here's what my app_dev.php file looks like:

#!/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);

If anyone could point me in the right direction that would be great thanks!

3
What version of Symfony do you think you are using? Where did you download the project from? Your autoload sort of looks like S2.0. The other file sort of looks like a script of some kind? It's not the AppKernel file. - Cerad
Hi @Cerad. I'm using version 2.4. This is a client project. And you are correct my mistake -- that's not the AppKernel file its the app_dev.php file. I've made the correction in the original. - O2U
@1ed Already have Symfony installed correctly. I can run the standard install just fine. - O2U
Based on the autolad file the project actually written for symfony <2.3, based on the console (not app_dev.php) file I would say it's a symfony 2.2 project. How did you get the vendor files (composer install)? You should have a composer.json file which looks like this. - 1ed

3 Answers

3
votes

Please try.

composer install

Sometimes it could be as simple as this.

0
votes

Try to add

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

Thanks guys for your help. Turns out that I had mucked up my Apache installation so that it wasn't finding the intl extension. Once I got that installed again everything is well.