示例#1
0
 public function case_an_optional_argument_is_missing()
 {
     $this->given($router = new MockRouter(), $router->get('a', '(?<foo>foo)', __CLASS__, 'dispatchedMethodOptional'), $this->route($router, 'foo'), $dispatcher = new LUT\ClassMethod(), $dispatcher->getParameters()->setParameters(['synchronous.call' => '(:call:U:)', 'synchronous.able' => '(:able:)']))->when($dispatcher->dispatch($router));
 }
示例#2
0
            if (file_exists($path)) {
                require_once $path;
                break;
            }
        }
    }
}
Core::enableErrorHandler();
Core::enableExceptionHandler();
/**
 * Here we go!
 */
try {
    $router = new Router\Cli();
    $router->get('g', '(?:(?<vendor>\\w+)\\s+)?(?<library>\\w+)?(?::(?<command>\\w+))?(?<_tail>.*?)', 'main', 'main', ['vendor' => 'hoa', 'library' => 'core', 'command' => 'welcome']);
    $dispatcher = new Dispatcher\ClassMethod(['synchronous.call' => '(:%variables.vendor:lU:)\\(:%variables.library:lU:)\\Bin\\(:%variables.command:lU:)', 'synchronous.able' => 'main']);
    $dispatcher->setKitName('Hoa\\Console\\Dispatcher\\Kit');
    exit((int) $dispatcher->dispatch($router));
} catch (Core\Exception $e) {
    $message = $e->raise(true);
    $code = 1;
} catch (\Exception $e) {
    $message = $e->getMessage();
    $code = 2;
}
ob_start();
Console\Cursor::colorize('foreground(white) background(red)');
echo $message, "\n";
Console\Cursor::colorize('normal');
$content = ob_get_contents();
ob_end_clean();
示例#3
0
<?php

require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Hoa\Exception;
use Hoa\Dispatcher;
use Hoa\Router;
Exception\Error::enableErrorHandler();
Exception\Idle::enableUncaughtHandler();
$dispatcher = new Dispatcher\ClassMethod(['synchronous.call' => 'Application\\Resource\\(:call:U:)', 'synchronous.able' => '(:%variables._method:U:)', 'asynchronous.call' => '(:%synchronous.call:)', 'asynchronous.able' => '(:%synchronous.able:)']);
$router = new Router\Http();
$router->_get('_resource', '/Static/(?<resource>)')->get('dates', '/api/dates(?:/(?<limit>\\d+))?', 'Dates')->get('discography', '/api/discography', 'Discography')->get('album', '/api/album/(?<albumId>.+)', 'Album')->get('videos', '/api/videos', 'Videos')->get('fallback', '/.*', 'Fallback');
$dispatcher->dispatch($router);
示例#4
0
文件: index.php 项目: Jir4/Natibat
// Fichier de config
require_once 'config.php';
// Le script va afficher du français
if (PHP_OS == 'Linux') {
    setlocale(LC_ALL, 'fr_FR.UTF-8');
} else {
    setlocale(LC_ALL, 'French');
}
// Déclaration des NS utilisés
use Hoa\Core;
use Hoa\Dispatcher;
use Hoa\Router;
// Activation des erreurs
Core::enableErrorHandler();
Core::enableExceptionHandler();
// Mise en place du dispatcher
$dispatcher = new Dispatcher\ClassMethod(['synchronous.call' => 'Application\\Controller\\(:call:U:)', 'asynchronous.able' => '(:%synchronous.able:)']);
// Connection à la base de donnée
Hoa\Database\Dal::initializeParameters(array('connection.list.default.dal' => Hoa\Database\Dal::PDO, 'connection.list.default.dsn' => SQL_DNS, 'connection.list.default.username' => SQL_USER, 'connection.list.default.password' => SQL_PWD, 'connection.list.default.options' => array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"), 'connection.autoload' => 'default'));
// Utilisation d'un Kit personnalisé
$dispatcher->setKitName('Application\\Dispatcher\\Kit');
$router = new Router\Http();
// Déclaration des routes
$router->get('Home', '/', 'Index', 'Index')->post('Login', '/', 'Index', 'Login')->get('Logout', '/Logout', 'Index', 'Logout');
// Here we go !
try {
    $dispatcher->dispatch($router);
} catch (Hoa\Dispatcher\Exception $e) {
    echo $e->getMessage();
    //echo 'Page Introuvable';
}