Last active
February 3, 2016 13:23
-
-
Save jenkoian/641dcca3e47fc321825e to your computer and use it in GitHub Desktop.
Escape route from legacy index.php
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 | |
// Composer autoloader | |
$loader = require __DIR__ . '/../vendor/autoload.php'; | |
// Legacy config which includes legacy autoloader stuff | |
require_once __DIR__ . '/../html/config.php'; | |
// Legacy bootstrapping code wrapped in a class implementing HttpKernelInterface to make it stackable | |
require __DIR__ . '/../html/Bootstrap.php'; | |
use Acme\AppKernel; | |
use Doctrine\Common\Annotations\AnnotationRegistry; | |
// Load up annotations | |
AnnotationRegistry::registerLoader(array($loader, 'loadClass')); | |
// Load up AppKernel, $symfony_env is set in the legacy config file | |
$debug = $symfony_env !== 'prod'; | |
$kernel = new AppKernel($symfony_env, $debug); | |
$kernel->loadClassCache(); | |
// Create a Stack Builder | |
$stack = new Stack\Builder(); | |
// Stack the Symfony Application using a pre-made SymfonyMiddleware | |
$stack->push('Mouf\StackPhp\SymfonyMiddleware', $kernel); | |
// Run the stack with the legacy app lazy loaded(so it doesn't get bootstrapped) | |
Stack\run( | |
$stack->resolve( | |
Stack\lazy(function() { | |
return new Bootstrap(); | |
}) | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment