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) );
@claudio-dalicandro
Copy link

No va beh, il commento era sulla precedente revisione, questa mi sembra abbastanza accettabile 🚬

@claudio-dalicandro
Copy link

👍 la versione 3 è perfetta

@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