Beispiel #1
0
 protected function setUp()
 {
     $cache1 = Ham::create_cache('default', True);
     $app = new Ham('default', $cache1, 'log.txt');
     $app->route('/', function ($app) {
         return 'hello world';
     });
     $app->route('/hello/<string>', function ($app, $name) {
         return "hello {$name}";
     });
     $app->route('/timestwo/<int>', function ($app, $int) {
         return $int * 2;
     });
     $app->route('/add/<int>/<int>', function ($app, $a, $b) {
         return $a + $b;
     });
     $app->route('/dividefloat/<float>/<float>', function ($app, $a, $b) {
         if ($b == 0) {
             return 'NaN';
         }
         return $a / $b;
     });
     $beans = new Ham('beans', $cache1);
     $beans->route('/', function ($app) {
         return "beans";
     });
     $beans->route('/baked', function ($app) {
         return "yum";
     });
     $app->route('/beans', $beans);
     $this->app = $app;
 }
Beispiel #2
0
 public function __construct($name, $cache = null, $logger = null)
 {
     $this->_twig_env = new Twig_Environment(new Twig_Loader_Filesystem($this->template_paths));
     parent::__construct();
 }
Beispiel #3
0
<?php

require '../ham/ham.php';
$beans = new Ham('beans');
$beans->route('/', function ($app) {
    return "Beans home.";
});
$beans->route('/baked', function ($app) {
    return "Yum!";
});
$app = new Ham('example', false, 'logs/' . date('Y-m-d') . '.txt');
$app->route('/', function ($app) {
    $app->logger->log('Home requested');
    return "Home.";
});
$app->route('/', function ($app) {
    return "Home.";
});
$app->route('/hello/<string>', function ($app, $name) {
    return $app->render('hello.html', array('name' => $name));
});
$app->route('/beans', $beans);
$app->run();
});
$mux = (require 'pux/hello_mux.php');
$bench->iterate('pux', function () use($mux) {
    $route = $mux->match('/hello');
});
// klein
$klein = new \Klein\Klein();
$klein->respond('GET', '/hello', function () {
    return 'hello';
});
$bench->iterate('klein', function () use($klein) {
    $klein->dispatch();
});
// ham
$_SERVER['REQUEST_URI'] = '/hello';
$ham = new Ham('example');
$ham->route('/hello', function ($ham) {
});
$bench->iterate('ham', function () use($ham) {
    $ham->run();
});
// aura
$aura = (require 'aura/aura/scripts/instance.php');
$aura->add('hello', '/hello');
$bench->iterate('aura', function () use($aura) {
    $route = $aura->match('/hello', $_SERVER);
});
// Symfony
$routes = new RouteCollection();
$routes->add('hello', new Route('/hello', array('controller' => 'foo', 'action' => 'bar')));
$bench->iterate('symfony/routing', function () use($routes) {