Exemplo n.º 1
0
<?php

//store this application configuration and free memory
Drivers\Registry::setConfig($config);
//free memory of this variable
//unset($config);
//store the database settings in the registry and free memory
Drivers\Registry::setSettings($database);
//free memory of this variable
//unset($database);
//store the request URI and free the memory
Drivers\Registry::setUrl(isset($_GET['url']) ? $_GET['url'] : '');
//set the application start time
Drivers\Registry::$gliver_app_start = $gliver_app_start;
Exemplo n.º 2
0
    require_once __DIR__ . '/Exceptions/Debug/BaseShutdown.php';
    //initilize native session
    session_start();
    //get the composer autoloader.php file
    require_once __DIR__ . '/../vendor/autoload.php';
    //load the defined constants
    require_once __DIR__ . '/../application/constants.php';
    //load system configuration settings into array
    $config = (require_once __DIR__ . '/../config/config.php');
    //load system database settings into array
    $database = (require_once __DIR__ . '/../config/database.php');
    //include the initializatoin file
    require_once __DIR__ . '/initialize.php';
    //set the class aliases, so they are available to our closure objects
    //loop through aliases autoloading
    foreach (Drivers\Registry::getConfig()['aliases'] as $aliasNamespace => $aliasName) {
        //register and lazy autoload the aliases(class)
        class_alias($aliasNamespace, $aliasName);
    }
    //get closure object instance to launch application
    $start = (require_once __DIR__ . '/start.php');
    //lauch application instance
    $start();
} catch (Exception $e) {
    $error = <<<ERROR
\t<!DOCTYPE html>
\t<html>
\t<head>
\t    <meta charset="utf-8">
\t    <meta http-equiv="X-UA-Compatible" content="IE=edge">
\t    <meta name="viewport" content="width=device-width, initial-scale=1">
Exemplo n.º 3
0
     //check of the routes configuration file exists
     if (!file_exists(__DIR__ . '/../application/routes.php')) {
         throw new Drivers\Routes\RouteException("Drivers\\Routes\\RouteException : The defined routes.php file cannot be found! Please restore if you deleted");
     }
     //get the defined routes
     $definedRoutes = (include __DIR__ . '/../application/routes.php');
 } catch (Drivers\Routes\RouteException $ExceptionObjectInstance) {
     //display the error message to the browser
     $ExceptionObjectInstance->errorShow();
 }
 //create an instance of the UrlParser Class,
 $UrlParserObjectInstance = new Drivers\Utilities\UrlParser(Drivers\Registry::getUrl(), Drivers\Registry::getConfig()['url_component_separator']);
 //and set controller, method and request parameter
 $UrlParserObjectInstance->setController()->setMethod()->setParameters();
 //create an instance of the route parser class
 $RouteParserObject = new Drivers\Routes\RouteParser(Drivers\Registry::getUrl(), $definedRoutes, $UrlParserObjectInstance);
 //check if there is infered controller from url string
 if ($UrlParserObjectInstance->getController() !== null) {
     //check if there is a defined route matched
     if ($RouteParserObject->matchRoute()) {
         //if there is a defined route, set the controller, method and parameter properties
         $RouteParserObject->setController()->setMethod()->setParameters();
         //set the value of the controller
         $controller = $RouteParserObject->getController();
         //set the value of the method
         ($action = $RouteParserObject->getMethod()) || ($action = $config['default']['action']);
     } else {
         //set the parameter properties
         $RouteParserObject->setParameters();
         //get the controller name
         $controller = $UrlParserObjectInstance->getController();
Exemplo n.º 4
0
<?php

//store this application configuration and free memory
Drivers\Registry::setConfig($config);
//free memory of this variable
//unset($config);
//store the database settings in the registry and free memory
Drivers\Registry::setSettings($database);
//free memory of this variable
//unset($database);
//store the request URI and free the memory
Drivers\Registry::setUrl(isset($_GET['url']) ? $_GET['url'] : '');
Exemplo n.º 5
0
 } catch (Exceptions\BaseException $error) {
     $error->show();
     return;
 }
 $routeObj = new Drivers\Routes\Implementation();
 //there is a defined route
 if ($routeObj->dispatch(Drivers\Registry::getUrl(), $routes)) {
     //get the controller name
     ($controller = $routeObj->getController()) || ($controller = $config['default']['controller']);
     //get the action name
     ($action = $routeObj->getMethod()) || ($action = $config['default']['action']);
     //get parameters
     $parameters = $routeObj->getParameters();
 } else {
     //create an instance of the url parser
     $urlObj = new Drivers\Utilities\UrlParser(Drivers\Registry::getUrl());
     //get the controller name
     ($controller = $urlObj->getController()) || ($controller = $config['default']['controller']);
     //get the action name
     ($action = $urlObj->getMethod()) || ($action = $config['default']['action']);
     //get parameters
     $parameters = $urlObj->getParameters();
 }
 //check if this class and method exists
 try {
     //get the namespaced controller class
     $controller = 'Controllers\\' . ucwords($controller) . 'Controller';
     if (!class_exists($controller)) {
         throw new Exceptions\BaseException("The class " . $controller . ' is undefined');
     }
     if (!(int) method_exists($controller, $action)) {