Skip to content

Instantly share code, notes, and snippets.

@simodima
Last active August 29, 2015 14:03
Show Gist options
  • Save simodima/9519f8555c1f84c3d6ff to your computer and use it in GitHub Desktop.
Save simodima/9519f8555c1f84c3d6ff to your computer and use it in GitHub Desktop.
A brand new implementatio of "Front Controller" Design Pattern
<?php
use Symfony\Component\HttpFoundation\Request;
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$crazyReParser = function ($string, $reMapper) {
return str_replace(
[
'$S',
'P',
'::',
'Q',
'R'
],
$reMapper,
$string
);
};
$reMapper = [
'$response',
'send();',
'',
'$kernel->terminate',
'$request, $response'
];
eval( $crazyReParser("$S->P::Q(R);" , $reMapper) );
@liuggio
Copy link

liuggio commented Jun 27, 2014

ahahah fantastico

io avevo pensato a

<?php

define('R','R');
function Q($R) {}
$S = new \stdClass();
$S->P = '';

$S->P;;Q(R);

Ma il tuo è geniale

@npget
Copy link

npget commented Jul 1, 2014

Fortissimo ,
MA .... ?? Non so ?? ma una mini spiegazione su cosa fa o su cosa essere $crazyReParser ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment