Пример #1
0
 static function registerAutoload()
 {
     if (self::$loaded) {
         return;
     }
     self::$loaded = true;
     spl_autoload_register(function ($clsName) {
         $path = str_replace('_', DIRECTORY_SEPARATOR, $clsName) . '.php';
         require_once $path;
     });
     if (php_sapi_name() == 'cli' && strpos($GLOBALS['argv'][0], 'phpunit') !== false) {
         self::autoload(__DIR__, dirname(__DIR__) . '/tests/');
         $autoload = __DIR__ . '/../vendor/autoload.php';
         if (is_readable($autoload)) {
             require_once $autoload;
         }
     }
 }
Пример #2
0
<?php

$root = dirname(__DIR__);
define('VENDOR_DIR', $root . '/vendor/');
define('LIBRARY_DIR', $root . '/src/');
require VENDOR_DIR . '/Miper/Autoload.php';
Miper_Autoload::autoload(VENDOR_DIR, LIBRARY_DIR);
$app = Miper_App::getAppInstance();
$app->get(['/test/#{foo:?string}/#{userid}', function ($req) {
    return array('args' => $req->args);
}])->output()->end();
$app->get(['/hello/world', function ($req) {
    return 'Hello,World';
}])->output()->end();
$app->delegate('/user/', 'Happy_Delegate_User');
$app->error('msful.notfound', function ($msg, $detail) use($app) {
    header('HTTP/1.1 404 Not Found');
    return array('msg' => $msg, 'detail' => $detail);
});