Exemple #1
0
 /**
  * Run an application
  */
 public static function run()
 {
     // Error reporting
     error_reporting(ENV === 'production' ? E_ERROR | E_WARNING | E_PARSE : -1);
     ini_set('display_errors', ENV === 'production' ? 0 : 1);
     // Services
     $services = Services::getInstance();
     // Global configuration
     $config = $services->config()->get('config');
     // UTF-8 support
     if (isset($config['utf8']) && $config['utf8']) {
         mb_internal_encoding('UTF-8');
         mb_http_output('UTF-8');
         mb_http_input('UTF-8');
         mb_language('uni');
         mb_regex_encoding('UTF-8');
         ob_start('mb_output_handler');
     } else {
         ob_start();
     }
     // Set Locales
     if (isset($config['locale']) && $config['locale']) {
         setlocale(LC_ALL, $config['locale']);
         setlocale(LC_NUMERIC, 'C');
     }
     // Call controller
     if ($route = $services->route()) {
         list($class, $method, $params) = $route;
         $controller = new $class();
         $controller->{$method}(...$params);
     }
     $services->output()->display(!$services->input()->isClient());
     ob_end_flush();
 }
Exemple #2
0
 public function __construct()
 {
     $this->services = Services::getInstance();
     $this->input = $this->services->input();
     $this->output = $this->services->output();
 }