Example #1
0
<?php

require_once 'controller.php';
require_once 'view.php';
require_once 'model.php';
$model = new Model();
$controller = new Controller($model);
$view = new View($controller, $model);
//$controller->create_dummy();
echo $view->header();
echo $view->body();
echo $view->footer();
Example #2
0
 /**
  * Serve a specified http response code page by either executing a template or the passed \Closure $fun function, 
  * or loading the \Closure function from the file $this->errorDir . $code.php and executing it or by 
  * a default message set by the function.
  *
  *
  * @param int $code The http repsonse code sent to the client from the server.
  * @param boolean|string|\Closure $action A template or closure to execute when $code != 200.
  * @return void 
  */
 public final function serve($code = 200, $action = false)
 {
     if ($code != 200) {
         //set the response code
         http_response_code($code);
         //clear the body of the view
         \View::body('');
         if (is_string($action)) {
             \Template::with($action);
         } else {
             if ($action !== false && $action instanceof \Closure) {
                 call_user_func($action);
             } else {
                 $file = \App::path() . '/' . trim($this->errorDir, '/') . '/' . $code . '.php';
                 if (is_file($file)) {
                     $action = (require $file);
                     call_user_func($action, \App::instance());
                 }
                 //if
             }
         }
         //el
     }
     //if
     //Print out the Current View.
     if (!\App::instance()->cli) {
         \View::printPage();
     }
     //if
     exit;
 }