コード例 #1
0
ファイル: Router.php プロジェクト: spire-framework/spire
 /**
  * Initializes the Spire framework.
  *
  * @return void
  */
 public static function initialize()
 {
     // Start the system.
     Spire::start();
     // Load routes.
     static::routes();
     // Find the current route.
     $route = Repository::retrieve(Request::method(), Uri::segmentString());
     // If no route was found, show a 404.
     if (empty($route)) {
         die('404');
     }
     // Instantiate the module.
     static::$module = $module = new Module($route);
     // Run the module.
     $response = $module->run();
     // Run the response.
     if (is_object($response) && method_exists($response, 'respond')) {
         $response->respond();
     }
     // Do we have a layout to process?
     $layout = $module->instance()->layout;
     // Process layout.
     if ($layout !== '') {
         echo Layout::get($layout);
     }
     // Close Spire.
     Spire::close();
 }
コード例 #2
0
ファイル: Console.php プロジェクト: spire-framework/spire
 /**
  * Initializes the console.
  *
  * @return void
  */
 public static function initialize()
 {
     // Startup Spire.
     Spire::start();
     // Get the arguments.
     $arguments = $_SERVER['argv'] ?? [];
     // Clear the executed file from the arguments.
     array_shift($arguments);
     // Get the command and task.
     list($command, $task) = explode('::', $arguments[0]);
     // Get the final arguments by removing the command.
     array_shift($arguments);
     // Do we have a valid command?
     $class = static::$commands[$command] ?? false;
     // If so run it.
     if ($class) {
         $console = new $class();
         $message = $console->execute((string) $task, $arguments);
         if (is_string($message)) {
             Output::send($message);
         }
     }
     // Close Spire.
     Spire::close();
 }