Commit f35b3234 authored by Avris's avatar Avris

Inject root dir to App

parent 0b41871e
<?namespace Picco;class App{
function __construct($e){session_start();$s=$_SERVER;define('D',dirname($s['SCRIPT_FILENAME']).'/../');$l=strlen($r=@$s['PATH_INFO']);$u=explode('?',$s['REQUEST_URI'])[0];define('F',$l?substr($u,0,-$l):$u);define('R',rtrim($r,'/')?:'/');define('B',preg_replace('#/[^/]+\.php$#','',F).'/');define('E',$e);}
function __construct($d,$e){session_start();$s=$_SERVER;define('D',$d);$l=strlen($r=@$s['PATH_INFO']);$u=explode('?',$s['REQUEST_URI'])[0];define('F',$l?substr($u,0,-$l):$u);define('R',rtrim($r,'/')?:'/');define('B',preg_replace('#/[^/]+\.php$#','',F).'/');define('E',$e);}
function run(){$c=new Container();$c->router=new Router(\App\Routing::get());$c->view=new View;$q=$c->controllers=new\App\Controllers;$d=$c->dispatcher=new Dispatcher;\App\Services::get($c);
$t=function($f,$m)use($c,$q,$d){$r=(array)call_user_func_array([$q,$f],$m);return$d('response',[$c,&$r])?:$c->view->render($f,$r+['r'=>$c->router]);};
$d->error=function($c,$e)use($t){if(E)throw$e;return$t('error',[$c,$e]);};
......
......@@ -13,12 +13,11 @@ class Controllers {
}
$_SERVER = [
'SCRIPT_FILENAME' => __DIR__ . '/help/web/app_dev.php',
'PATH_INFO' => '/test/',
'REQUEST_URI' => '/base/app_dev.php/test/?foo=bar',
];
$a = new App(false);
$a = new App(__DIR__ . '/help/web/../',false);
a(session_id());
a(D === __DIR__ . '/help/web/../');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment