EkinoWordpressBundle
EkinoWordpressBundle copied to clipboard
Fatal error: Class 'Symfony\Component\HttpKernel\Kernel' not found in {project directory}\symfony\app\AppKernel.php on line 7
Hello; I'm interested in using symfony and Wordpress but at the first install a get this error Fatal error: Class 'Symfony\Component\HttpKernel\Kernel' not found in {project directory}\symfony\app\AppKernel.php on line 7 My PHP version is 5.6 My symfony version is 2.8 My wordpress version is 4.6.1
I am experiencing the same issue using the same versions (with a little tweaked worpdpress docker container)
@daifabde I think that example of wordpress index.php is outdated or use something new in Symfony 3.x. Try the new index.php file. It worked for me:
<?php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Retrieves or sets the Symfony Dependency Injection container
*
* @param ContainerInterface|string $id
*
* @return mixed
*/
function symfony($id)
{
static $container;
if ($id instanceof ContainerInterface) {
$container = $id;
return;
}
return $container->get($id);
}
$loader = require __DIR__.'/../symfony/app/autoload.php';
require_once __DIR__.'/../symfony/app/bootstrap.php.cache';
// Load application kernel
require_once __DIR__.'/../symfony/app/AppKernel.php';
$sfKernel = new AppKernel('dev', true);
$sfKernel->loadClassCache();
$sfKernel->boot();
// Add Symfony container as a global variable to be used in Wordpress
$sfContainer = $sfKernel->getContainer();
if (true === $sfContainer->getParameter('kernel.debug', false)) {
Debug::enable();
}
symfony($sfContainer);
$sfRequest = Request::createFromGlobals();
$sfResponse = $sfKernel->handle($sfRequest);
$sfResponse->send();
$sfKernel->terminate($sfRequest, $sfResponse);
As you will see the path to bootstrap.php.cache
was changed into app/
(older/newer versions of Symfony works with var/
but I haven't known what versions exactly). The error is related with autoload.php
(inexistent) in the original file by the same reasons (the Symfony versions).
I hope that it solves your headaches
As of 11/01/2017 and Symfony 3.3 :)
<?php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Retrieves or sets the Symfony Dependency Injection container
*
* @param ContainerInterface|string $id
*
* @return mixed
*/
function symfony($id)
{
static $container;
if ($id instanceof ContainerInterface) {
$container = $id;
return;
}
return $container->get($id);
}
$loader = require __DIR__.'/../symfony/vendor/autoload.php';
require_once __DIR__.'/../symfony/var/bootstrap.php.cache';
// Load application kernel
require_once __DIR__.'/../symfony/app/AppKernel.php';
$sfKernel = new AppKernel('dev', true);
$sfKernel->loadClassCache();
$sfKernel->boot();
// Add Symfony container as a global variable to be used in Wordpress
$sfContainer = $sfKernel->getContainer();
if (true === $sfContainer->getParameter('kernel.debug', false)) {
Debug::enable();
}
symfony($sfContainer);
$sfRequest = Request::createFromGlobals();
$sfResponse = $sfKernel->handle($sfRequest);
$sfResponse->send();
$sfKernel->terminate($sfRequest, $sfResponse);
autoload.php
will be located at: symfony/vendor/autoload.php
And bootstrap.php.cache
at: symfony/var/bootstrap.php.cache