Skip to content

Instantly share code, notes, and snippets.

@chrisguitarguy
Last active June 2, 2019 03:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisguitarguy/07d6b9df23c6984fa5424c5a18b81f7e to your computer and use it in GitHub Desktop.
Save chrisguitarguy/07d6b9df23c6984fa5424c5a18b81f7e to your computer and use it in GitHub Desktop.
<?php
use Symfony\Component\HttpKernel\Kernel;
class AppKernel extends Kernel
{
public static function fromEnvironment()
{
$env = getenv('APP_ENVIRONMENT') ?: 'prod';
$debug = filter_var(getenv('APP_DEBUG'), FILTER_VALIDATE_BOOLEAN);
return new self($env, $debug);
}
// ...
}
<?php
use Symfony\Component\HttpFoundation\Request;
// require autoloader or bootstrap
require __DIR__ . '/../app/autoload.php';
// from the environment!
$app = AppKernel::fromEnvironment();
// just like normal
$request = Request::createFromGlobals();
$response = $app->handle($request);
$response->send();
$app->terminate($request, $response);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment