Ejemplo n.º 1
0
<?php

use Arvici\Component\Router;
/**
 * Router Configuration
 */
Router::define(function (Router $router) {
    $router->get('/', '\\App\\Controller\\Welcome::index');
    $router->get('/session', '\\App\\Controller\\Welcome::session');
    $router->get('/json', '\\App\\Controller\\Welcome::json');
    $router->get('/exception', '\\App\\Controller\\Welcome::exception');
});
Ejemplo n.º 2
0
 public static function clearRoutes()
 {
     Router::getInstance()->clearRoutes();
 }
Ejemplo n.º 3
0
 public function testApiRoutes()
 {
     TestUtils::clearRoutes();
     Router::api('api', 'test', 'App\\Controller\\Api\\TestObject');
     $this->spoof('/api/test/1', 'GET');
     try {
         Router::getInstance()->run();
         $this->assertTrue(false);
     } catch (\Exception $e) {
         $this->assertEquals("TEST-GET", $e->getMessage());
     }
     $this->spoof('/api/test', 'POST');
     try {
         Router::getInstance()->run();
         $this->assertTrue(false);
     } catch (\Exception $e) {
         $this->assertEquals("TEST-POST", $e->getMessage());
     }
     $this->spoof('/api/test/1', 'PUT');
     try {
         Router::getInstance()->run();
         $this->assertTrue(false);
     } catch (\Exception $e) {
         $this->assertEquals("TEST-PUT", $e->getMessage());
     }
     $this->spoof('/api/test/1', 'DELETE');
     try {
         Router::getInstance()->run();
         $this->assertTrue(false);
     } catch (\Exception $e) {
         $this->assertEquals("TEST-DELETE", $e->getMessage());
     }
     $this->spoof('/api/test/1', 'PATCH');
     try {
         Router::getInstance()->run();
         $this->assertTrue(false);
     } catch (\Exception $e) {
         $this->assertEquals("TEST-UPDATE", $e->getMessage());
     }
     TestUtils::clearRoutes();
     Router::api('api', 'test', 'App\\Controller\\Api\\TestObject', 'GET');
     $this->spoof('/api/test/1', 'GET');
     try {
         Router::getInstance()->run();
         $this->assertTrue(false);
     } catch (\Exception $e) {
         $this->assertEquals("TEST-GET", $e->getMessage());
     }
     $this->spoof('/api/test', 'POST');
     Router::getInstance()->run();
     $this->assertTrue(true);
 }
Ejemplo n.º 4
0
 * @copyright  2016 Tom Valk
 */
use Arvici\Heart\Config\Configuration;
/**
 * Define the base directory containing the 'App' folder.
 */
defined('BASEPATH') || define('BASEPATH', __DIR__ . DS);
/**
 * Define all the paths in the base.
 */
defined('APPPATH') || define('APPPATH', BASEPATH . 'App' . DS);
/**
 * Load all configuration files.
 */
$configDir = APPPATH . '/Config/';
foreach (glob($configDir . '*.php') as $fileName) {
    require_once $fileName;
}
/**
 * Set default timezone
 */
date_default_timezone_set(Configuration::get('app.timezone', 'UTC'));
/**
 * Start the logger.
 */
\Logger::start();
/**
 * Start the router.
 */
\Arvici\Component\Router::getInstance()->run();