Example #1
0
<?php

// initialize sleepyMUSTACHE
require_once $_SERVER['DOCUMENT_ROOT'] . '/app/core/sleepy.php';
// basic routing with defaults
\Sleepy\Router::mvc(['{{ controller }}/{{ action }}/{{ id }}', '{{ controller }}/{{ action }}', '{{ controller }}', '/']);
// If the route throws an exception, show the 404 page
try {
    \Sleepy\Router::start();
} catch (\Sleepy\RouteNotFound $e) {
    \Sleepy\Router::redirect('home', 'pageNotFound', array('error' => $e));
} catch (\Exception $e) {
    \Sleepy\Router::redirect('home', 'error', array('error' => $e));
}
Example #2
0
 function testRouterQuerystring()
 {
     \Sleepy\Router::$querystring = true;
     \Sleepy\Router::route('/fruit/{{color}}', function ($route) {
         $this->assertEqual($route->params['color'], 'yellow');
         echo "fruit";
     });
     ob_start();
     \Sleepy\Router::start('/?q=/fruit/yellow');
     $this->assertEqual(ob_get_clean(), "fruit");
     \Sleepy\Router::$querystring = false;
 }