示例#1
0
 public function testSubDir()
 {
     $method = "POST";
     $host = "www.test.com";
     $uri = "/test/subdir/test/uri";
     $scriptName = "/test/subdir/test.php";
     $req = new \SlaxWeb\Router\Request();
     $req->setBaseRequest("http", $host, $method);
     $req->parseRequestUri($uri, $scriptName);
     $this->assertEquals("/test/subdir", $req->dir);
     $this->assertEquals("test/uri", $req->uri);
     $this->assertEquals("POST", $req->method);
     $this->assertEquals("www.test.com", $req->domain);
 }
示例#2
0
<?php

require_once "../vendor/autoload.php";
$container = new Pimple\Container();
$container["service.request"] = $container->factory(function (Pimple\Container $c) {
    $request = new SlaxWeb\Router\Request();
    if ($c["router.protocol"] === "cli") {
        $request->setUpCLI($c["router.uri"]);
    }
    return $request;
});
$container["service.router"] = $container->factory(function (Pimple\Container $c) {
    $request = $c["service.request"];
    $router = new SlaxWeb\Router\Router($request);
    SlaxWeb\Router\Helper::init($router, $request);
    return $router;
});
$options = getopt("u:", ["uri:"]);
if (isset($options["u"])) {
    $options["uri"] = $options["u"];
}
$container["router.protocol"] = "cli";
$container["router.uri"] = $options["uri"];
$router = $container["service.router"];
require_once "../app/routes.php";
$action = $router->process();
$container["app.action"] = $action["action"];
$container["app.params"] = $action["params"];
$container["app.action"];