Esempio n. 1
0
 public function testMuxCompiler()
 {
     $mux = new Mux();
     $mux->add('/hello/:name', array('FooController', 'index'));
     $mux->compile("hello_mux.php");
     $mux2 = new Mux();
     $mux2->add('/bye/:name', array('FooController', 'index'));
     $mux2->compile("bye_mux.php");
     $compiler = new MuxCompiler();
     ok($compiler->load("hello_mux.php"));
     ok($compiler->load("bye_mux.php"));
     $compiler->compileReflectionParameters();
     ok($compiler->compile("merged_mux.php"));
     path_ok("merged_mux.php");
     $mux = (require "merged_mux.php");
     ok($mux);
     $routes = $mux->getRoutes();
     ok($routes);
     count_ok(2, $routes);
     ok($mux->dispatch('/hello/John'));
     ok($mux->dispatch('/bye/John'));
     unlink("merged_mux.php");
     unlink("hello_mux.php");
     unlink("bye_mux.php");
 }
Esempio n. 2
0
 public function execute()
 {
     $files = func_get_args();
     $outputFile = $this->options->o ?: '_mux.php';
     $compiler = new MuxCompiler();
     foreach ($files as $file) {
         $compiler->load($file);
     }
     $compiler->compile($outputFile);
 }
Esempio n. 3
0
<?php

// require '../vendor/autoload.php';
require '../src/Pux/PatternCompiler.php';
require '../src/Pux/Mux.php';
require '../src/Pux/MuxCompiler.php';
use Pux\MuxCompiler;
use Pux\Mux;
class HelloController
{
    public function helloAction()
    {
        return 'hello';
    }
}
$compiler = new MuxCompiler();
$compiler->load('hello_routes.php');
$compiler->compile('hello_mux.php');