/**
  * Run the application
  */
 public function run()
 {
     if ($this->debug) {
         Log::write('Trying to run the application...');
     }
     try {
         $this->configure();
     } catch (\Exception $e) {
         $errorMessage = 'Exception occurred while configuring application : ' . $e;
         Log::write($errorMessage);
         if ($this->debug) {
             echo '<pre>' . htmlspecialchars($errorMessage) . '<pre>';
         }
     }
     Log::write('Application is running...');
     try {
         $this->router->listen();
     } catch (\Exception $e) {
         $errorMessage = 'Exception occurred while running application : ' . $e;
         Log::write($errorMessage);
         if ($this->debug) {
             echo '<pre>' . htmlspecialchars($errorMessage) . '<pre>';
         }
     }
 }
Example #2
0
<?php

/**
 * ==============================
 * Aegis Framework | MIT License
 * http://www.aegisframework.com/
 * ==============================
 */
// Uncomment on Production
//error_reporting(0);
include "lib/aegis.php";
$session = new Session();
$router = new Router("localhost/Kirino");
$meta = ["title" => "Kirino - Virtual Assistant Chatbot", "description" => "Kirino, is an artificial intelligence chatbot, who will help you as a personal assistant and friend.", "keywords" => "assistant,intelligence,virtual,bot,chat,tak,converse,discuss,ai,ia,kirino,hyuchia,friend", "author" => "Diego Islas Ocampo", "twitter" => "@HyuchiaDiego", "google" => "+HyuchiaDiego", "domain" => $router->getBaseUrl(), "route" => $router->getFullUrl(), "year" => date("Y"), "shareimage" => "share.png"];
if (!$session->get("logged")) {
    $router->registerRoute("/", new View("main", ["main" => ["year" => $meta["year"]]], $meta));
} else {
    $router->registerRoute("/", new View("loggin", ["loggin" => ["year" => $meta["year"]]], $meta));
}
$router->listen();
Example #3
0
<?php

/* 
 * Created by Hei
 */
function defaultController()
{
    echo 'This is defaultController';
}
Router::listen('GET', '/simphpfy/', 'defaultController');
Router::listen('GET', '/simphpfy/redirect/:{[0-9a-zA-Z_]+\\.jpg}', '/simphpfy/Member/Index');
Router::listen('GET', 'simphpfy/view/$id:ID', function ($request) {
    echo 'This is closure function<br />';
    echo '$id is ' . $request->params['id'];
});
Router::listen('GET', '/simphpfy/:Controller/:Action/$id:ID/*');
Router::listen('GET', '/simphpfy/:Controller/:Action/$id:ID/**');
Router::listen('GET', '/simphpfy/redirect/member', array('controller' => 'Member', 'action' => 'Index'));
Router::listen('GET', '/simphpfy/:Controller/:Action/$id:ID/**/test');
/*Router::listen(array('GET', 'POST'), '/:Controller/:Action/$id:{[0-9]+}/:{*}', array(
        'controller' => '', 
        'action' => ''
    ), function(){}
);*/
Router::dispatch();
Example #4
0
<?php

/* 
 * Created by Hei
 */
Router::listen('GET', DIRECTORY_PREFIX . '$controller:Controller', function ($request) {
    $url = SIMPHPFY_RELATIVE_PATH . $request->params['controller'] . '/Index';
    header("location: {$url}");
    die;
});
Router::listen('GET', DIRECTORY_PREFIX . '__WebDocument/$base64:*', function ($request) {
    $file = base64_decode(urldecode($request->params['base64']));
    if (!file_exists($file)) {
        throw new FileNotFoundException('File not found');
    }
    header('Content-Type: ' . Mimetype::fromPath($file));
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    readfile($file);
    exit;
});
Router::listen(array('GET', 'POST', 'PUT', 'DELETE'), DIRECTORY_PREFIX . ':Controller/:Action');
Router::listen(array('GET', 'POST', 'PUT', 'DELETE'), DIRECTORY_PREFIX . ':Controller/:Action/$id:ID');
Example #5
0
<?php

/**
 * ==============================
 * Aegis Framework | MIT License
 * http://www.aegisframework.com/
 * ==============================
 */
include "lib/aegis.php";
$session = new Session();
// Aegis::$debugging = false;
Router::$domain = "localhost/AegisFramework";
Router::get("/", function () {
    return new main();
});
Router::listen();