Example #1
0
 private function startController()
 {
     $router = new router();
     $controller = "controllers\\" . $router->getController();
     $this->controller = $controller;
     $this->controllerstring = "controllers_" . $router->getController();
     $obj = new $controller();
     $method = $router->getAction();
     $this->action = $method;
     try {
         $obj->{$method}();
         $this->view = $obj;
         if (!empty($obj->view)) {
             $this->viewfile = $obj->view;
         } else {
             $this->viewfile = $method;
         }
     } catch (\Exception $e) {
         $this->render = '<p class="errorMessage">' . $e->getMessage() . '</p>';
     }
 }
Example #2
0
    } else {
        if (file_exists(ROOT . DS . CONTROLLERS_DIR . DS . $class . '.php')) {
            require_once ROOT . DS . CONTROLLERS_DIR . DS . $class . '.php';
        } else {
            if (file_exists(ROOT . DS . VIEWS_DIR . DS . $class . '.php')) {
                require_once ROOT . DS . VIEWS_DIR . DS . $class . '.php';
            } else {
                if (file_exists(ROOT . DS . APP_DIR . DS . "class" . DS . strtolower($class) . '.php')) {
                    require_once ROOT . DS . APP_DIR . DS . "class" . DS . strtolower($class) . '.php';
                }
            }
        }
    }
}
spl_autoload_register('my_autoloader');
/**
 * Start sesji.
 */
session::initialize();
/**
 * Konfiguracja routingu
 */
$router = new router();
$router->setRoute(new route("index", "AppController", "index"));
$router->setRoute(new route("test", "TestController", "test"));
/**
 * Start aplikacji
 */
$controller = $router->getController();
$action = $router->getAction($controller);
$controller->{$action}();