PHP code example of bangpound / legacy-php-http-kernel

1. Go to this page and download the library: Download bangpound/legacy-php-http-kernel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bangpound / legacy-php-http-kernel example snippets



Bangpound\LegacyPhp\EventListener\OutputBufferListener;
use Bangpound\LegacyPhp\EventListener\ShutdownListener;
use Bangpound\LegacyPhp\HttpKernel;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestMatcher;
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;

// Use a request attribute to identify requests which are legacy.
$matcher = new RequestMatcher();
$matcher->matchAttribute('_legacy', 'true');

$dispatcher = new EventDispatcher();

// Event listeners make Symfony reponses from output buffer and
// register a shutdown handler.
$dispatcher->addSubscriber(new OutputBufferListener($matcher));
$dispatcher->addSubscriber(new ShutdownListener($matcher));

// Add a listener that modifies every request to have a controller
// that imitates Wordpress index.php.
$dispatcher->addListener(KernelEvents::REQUEST,

    function (GetResponseEvent $event) {
        $request = $event->getRequest();
        $request->attributes->add(array(
            '_legacy' => 'true',
            '_controller' => function () {
                define('WP_USE_THEMES', true);
                
`json
{
	"ound/legacy-php-http-kernel": "1.0.*"
	}
}