Difference between revisions of "Developers/Custom Kernel"
From PartKeepr Wiki
(Created page with "Sometimes it's required to use additional bundles. Since the bundle list in the [https://github.com/partkeepr/PartKeepr/blob/master/app/AppKernel.php AppKernel] is pretty much...") |
(No difference)
|
Revision as of 16:35, 14 December 2015
Sometimes it's required to use additional bundles. Since the bundle list in the AppKernel is pretty much static and there's no plugin system yet, the recommended way is to create a custom kernel:
# app/MyCustomAppKernel.php use Symfony\Component\HttpKernel\Kernel; class MyCustomAppKernel extends Kernel { public function getCustomBundles () { $customBundles = []; $customBundles[] = new My\Custom\Bundle(); return $customBundles; } }
Then create a custom app.php which uses the custom app kernel:
<?php 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. /* $apcLoader = new ApcClassLoader('sf2', $loader); $loader->unregister(); $apcLoader->register(true); */ require_once __DIR__.'/../app/MyCustomAppKernel.php'; //require_once __DIR__.'/../app/AppCache.php'; $kernel = new MyCustomAppKernel('prod', false); $kernel->loadClassCache(); //$kernel = new AppCache($kernel); $request = Request::createFromGlobals(); $response = $kernel->handle($request); $response->send(); $kernel->terminate($request, $response);
To avoid overwriting, you can create a file like app_custom.php and set your DirectoryIndex to that file.