helionogueir/routing

一个用于控制HTTP请求路由的库

v1.0.0 2016-12-09 18:18 UTC

This package is not auto-updated.

Last update: 2024-09-23 12:16:54 UTC


README

一个用于控制HTTP请求路由的库。

安装

Composer (https://getcomposer.org.cn/) 和 (https://packagist.org.cn/)

composer require helionogueir/routing

使用

helionogueir\routing\route\Factory

加载route.json文件并构建一个"helionogueir\routing\Route"对象

use helionogueir\routing\route\Factory;
$namespace = "path/to/request";
$directory = "./routing/tests";
$route = Factory::byFile($namespace, $directory);

helionogueir\routing\server\Autoload

为spl_autoload_register定义一个新的角色

use helionogueir\routing\server\Autoload;
(new Autoload())->registerRoot("./routing/core");

helionogueir\routing\Route

构建一个新的"helionogueir\routing\Route"对象

use helionogueir\routing\Route;
$request = "route";
$className = "helionogueir\\routing\\server\\Autoload";
$method = "registerRoot";
$route = new Route($request, $className, $method);
$className = $route->getClassName();
(new $className())->{$route->getMethod()}("./routing/core");

测试驱动开发(TDD)

PHPUnit (https://phpunit.de/)

phpunit -c ./routing/tests/unit.xml