What app.php looks like for APC and Symfony 2.1

I would like to preload the app.php file with Symfony 2.1 and APC. I accepted the standard version of Symfony, set it up with the doctrine, and then made the changes described here: http://symfony.com/doc/2.1/book/performance.html

<?php require_once __DIR__.'\..\vendor\symfony\symfony\src\Symfony\Component\ClassLoader\UniversalClassLoader.php'; require_once __DIR__.'\..\vendor\symfony\symfony\src\Symfony\Component\ClassLoader\ApcUniversalClassLoader.php'; use Symfony\Component\ClassLoader\ApcClassLoader; use Symfony\Component\HttpFoundation\Request; $loader = new ApcClassLoader('sf2', $loader); $loader->register(true); require_once __DIR__.'/../app/AppKernel.php'; $kernel = new AppKernel('prod', false); $kernel->loadClassCache(); $request = Request::createFromGlobals(); $response = $kernel->handle($request); $response->send(); $kernel->terminate($request, $response); ?> 

but it does not work, I got an error:

 Fatal error: Class 'Symfony\Component\HttpKernel\Kernel' not found in __my_path__\app\AppKernel.php on line 7 

How do I prepare app.php for better performance.

+4
source share
1 answer

Take a look at the default app.php file in the standard Symfony distribution. To enable APC, your app.php file should look like this:

 use Symfony\Component\ClassLoader\ApcClassLoader; use Symfony\Component\HttpFoundation\Request; $loader = require_once __DIR__.'/../app/bootstrap.php.cache'; // Use APC for autoloading to improve performance. // Change 'sf2' to a unique prefix in order to prevent cache key conflicts // with other applications also using APC. $loader = new ApcClassLoader('sf2', $loader); $loader->register(true); require_once __DIR__.'/../app/AppKernel.php'; //require_once __DIR__.'/../app/AppCache.php'; $kernel = new AppKernel('prod', false); $kernel->loadClassCache(); //$kernel = new AppCache($kernel); $request = Request::createFromGlobals(); $response = $kernel->handle($request); $response->send(); $kernel->terminate($request, $response); 

You can also improve performance if you enable the symfony cache key by uncommenting the require_once __DIR__.'/../app/AppCache.php'; and $kernel = new AppCache($kernel); .

+6
source

All Articles