Commit fb4dbbd9 authored by Andrzej Prusinowski's avatar Andrzej Prusinowski

short tags

parent 637a83a8
Pipeline #3933961 (#) passed with stage
in 4 seconds
......@@ -14,5 +14,8 @@
"autoload": {
"psr-4": { "Picco\\": ["src"] }
},
"autoload-dev": {
"psr-4": { "Picco\\": ["tests"] }
},
"bin": ["picco"]
}
#!/usr/bin/env php
<?php
while(@$i<4)if(file_exists($l=($d=__DIR__.str_repeat('/..',@$i++)).'/vendor/autoload.php')){require$l;break;}
<?while(@$i<4)if(file_exists($l=($d=__DIR__.str_repeat('/..',@$i++)).'/vendor/autoload.php')){require$l;break;}
define('D',"$d/");define('AB',"$d/web");define('E',true);
$c=new Picco\Container;$c->dispatcher=new Picco\Dispatcher;App\Services::get($c);$a=$argv;$s='array_shift';$s($a);
if(!is_callable($d=[new App\Tasks,$m=$s($a)?:'help']))throw new Exception("Undefined task $m");call_user_func_array($d,array_merge([$c],$a));
\ No newline at end of file
<?php
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'],2)[0];define('F',$l?substr($u,0,-$l):$u);define('R',rtrim($r,'/')?:'/');define('B',preg_replace('#/[^/]+\.php$#','',F).'/');define('E',$e);}
<?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 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->trigger('response',[$c,&$r])?:$c->view->render($f,$r+['r'=>$c->router]);};
$d->set('error',function($c,$e)use($t){if(E)throw$e;return$t('error',[$c,$e]);});
......
<?php
namespace Picco;class Container{protected$s,$r;
<?namespace Picco;class Container{protected$s,$r;
function __set($n,$v){$this->s[$n]=$v;}
function __get($n){return isset($this->r[$n])?$this->r[$n]:$this->r[$n]=is_callable($s=$this->s[$n])?$s($this):$s;}}
\ No newline at end of file
<?php
namespace Picco;class Dispatcher{protected$e;
<?namespace Picco;class Dispatcher{protected$e;
function set($n,$c){$this->e[$n][]=$c;}
function trigger($n,$a){foreach((array)@$this->e[$n]as$e)if(null!==$r=call_user_func_array($e,$a))return$r;}}
\ No newline at end of file
<?php
namespace Picco;class Router{protected$r;
<?namespace Picco;class Router{protected$r;
function __construct($r){$this->r=$r;}
function match($u){foreach($this->r as$n=>$p)if(preg_match("#^$p$#",$u,$m))return[$n,$m];throw new\Exception("Route for $u not found",404);}
function get($c,$o=[]){return F.(rtrim(strtr(preg_replace_callback('#\([^(]*\)#',function()use($o){static$count=0;return@$o[$count++];},$this->r[$c]),['?'=>'']),'/')?:'/');}}
\ No newline at end of file
<?php
namespace Picco;class View{function render($v,$p=[]){unset($p['v']);extract($p);ob_start();require D."views/$v.phtml";return ob_get_clean();}}
\ No newline at end of file
<?namespace Picco;class View{function render($v,$p=[]){unset($p['v']);extract($p);ob_start();require D."views/$v.phtml";return ob_get_clean();}}
\ No newline at end of file
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