/**
  * @param string|TextResponse $message : the error message to display
  * @param int $code : the HTTP response code
  */
 public function __construct($message, int $code = 500)
 {
     if (!Config::getBool('debug')) {
         // only show the full error message in debug environments
         $message = '<h1>Internal server error</h1>';
         $code = 500;
     }
     parent::__construct($message);
     $this->code = $code;
 }
Esempio n. 2
0
 public static function getDefault() : UrlParameter
 {
     return new static(Config::get('app.languages.default'));
 }
Esempio n. 3
0
 /**
  * @param string $rootDir : the root directory of the project
  */
 public static function run(string $rootDir)
 {
     if (!is_dir($rootDir . '/app/')) {
         throw new RuntimeException('Invalid root directory, must contain /app/');
     }
     define('ROOT_DIR', $rootDir);
     define('LOG_DIR', ROOT_DIR . '/logs');
     self::init();
     // user initializers, event bindings, etc
     if (file_exists(ROOT_DIR . '/app/bootstrap.php')) {
         require ROOT_DIR . '/app/bootstrap.php';
     }
     // routes
     if (file_exists(ROOT_DIR . '/app/routes.php')) {
         require ROOT_DIR . '/app/routes.php';
     } else {
         throw new RuntimeException('No routes defined, what do you expect to see here?');
     }
     $timezone = Config::get('timezone');
     if (!empty($timezone)) {
         date_default_timezone_set($timezone);
     }
     self::render();
 }