Last active
January 4, 2016 11:59
-
-
Save bdunogier/8619032 to your computer and use it in GitHub Desktop.
eZ Publish extensible kernel example files (see https://github.com/ezsystems/ezpublish-community/pull/97)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// FILE: app/vm.ezpublish5/AppKernel.php | |
use Symfony\Component\Config\Loader\LoaderInterface; | |
class AppKernel extends EzPublishExtensibleKernel | |
{ | |
public function registerBundles() | |
{ | |
$bundles = array( | |
new BD\Bundle\TestBundle\BDTestBundle(), | |
); | |
$bundles = array_merge( | |
parent::registerBundles(), | |
$bundles | |
); | |
return $bundles; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
// FILE: app/vm.ezpublish5/console | |
// 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 ); | |
// Use autoload over boostrap here so we don't need to keep the generated files in git | |
require_once __DIR__.'/../../ezpublish/autoload.php'; | |
require_once __DIR__.'/../../ezpublish/EzPublishExtensibleKernel.php'; | |
require_once __DIR__.'/AppKernel.php'; | |
use eZ\Bundle\EzPublishCoreBundle\Console\Application; | |
use Symfony\Component\Console\Input\ArgvInput; | |
use Symfony\Component\Debug\Debug; | |
$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'; | |
if ( $debug ) | |
{ | |
Debug::enable(); | |
} | |
$application = new Application( new AppKernel( $env, $debug ) ); | |
$application->run( $input ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// FILE: app/vm.ezpublish5/web/index.php | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\ClassLoader\ApcClassLoader; | |
use Symfony\Component\Debug\Debug; | |
// Environment is taken from "ENVIRONMENT" variable, if not set, defaults to "prod" | |
$environment = getenv( "ENVIRONMENT" ); | |
if ( $environment === false ) | |
{ | |
$environment = "prod"; | |
} | |
#$loader = require_once __DIR__ . '/../../../ezpublish/bootstrap.php.cache'; | |
$loader = require_once __DIR__ . '/../../../ezpublish/autoload.php'; | |
// Depending on the USE_APC_CLASSLOADER environment variable, use APC for autoloading to improve performance. | |
// If not set it is not used. | |
if ( getenv( "USE_APC_CLASSLOADER" ) ) | |
{ | |
$prefix = getenv( "APC_CLASSLOADER_PREFIX" ); | |
$loader = new ApcClassLoader( $prefix ?: "ezpublish", $loader ); | |
$loader->register( true ); | |
} | |
require_once __DIR__ . '/../../../ezpublish/EzPublishCache.php'; | |
require_once __DIR__ . '/../../../ezpublish/EzPublishExtensibleKernel.php'; | |
require_once __DIR__ . '/../AppKernel.php'; | |
// Depending on the USE_DEBUGGING environment variable, tells whether Symfony should be loaded with debugging. | |
// If not set it is activated if in "dev" environment. | |
if ( ( $useDebugging = getenv( "USE_DEBUGGING" ) ) === false ) | |
{ | |
$useDebugging = $environment === "dev"; | |
} | |
if ( $useDebugging ) | |
{ | |
Debug::enable(); | |
} | |
$kernel = new AppKernel( $environment, $useDebugging ); | |
//$kernel->loadClassCache(); | |
// Depending on the USE_HTTP_CACHE environment variable, tells whether the internal HTTP Cache mechanism is to be used. | |
// If not set it is activated if not in "dev" environment. | |
if ( ( $useHttpCache = getenv( "USE_HTTP_CACHE" ) ) === false ) | |
{ | |
$useHttpCache = $environment !== "dev"; | |
} | |
// Load HTTP Cache ... | |
if ( $useHttpCache ) | |
{ | |
$kernel = new EzPublishCache( $kernel ); | |
} | |
$request = Request::createFromGlobals(); | |
// If you are behind one or more trusted reverse proxies, you might want to set them in TRUSTED_PROXIES environment | |
// variable in order to get correct client IP | |
if ( ( $trustedProxies = getenv( "TRUSTED_PROXIES" ) ) !== false ) | |
{ | |
Request::setTrustedProxies( explode( ",", $trustedProxies ) ); | |
} | |
$response = $kernel->handle( $request ); | |
$response->send(); | |
$kernel->terminate( $request, $response ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment