n0wada/chert
Composer 安装命令:
composer require n0wada/chert
包简介
It is a simple routing library using annotations and caching.
README 文档
README
It's an alternative to ControllerProvider for Silex application, using annotations and caching. Chert is inspired by Orlex
Install
Chert uses Composer to install:
"require": {
"n0wada/chert": "dev-master"
}
Parameters
chert.cache_dir
The cache directory. This library save RouteCollection Object there.
If you use FilesystemCache(default), This Parameter is required.
chert.cache_lifetime
The lifetime in number of seconds for this cache entry. default lifetime is 0.
chert.controller_dirs
It is an array of pairs of namespace and directory.
chert.cache
If you want to use ApcCache, MemCached, Redis etc., you can set Cache Object here.
You need to implements Doctrine\Common\Cache\Cache Interface.
Usage
Resister Provider in your Silex application.
$app = new \Silex\Application(); $app->register(new \Chert\RouteCompileServiceProvider(),[ 'chert.cache_dir' => __DIR__ . '/cache, 'chert.controller_dirs' => ['Controller' => __DIR__ . '/controllers] ]); $app->run();
Set up Routing in your Controller.
namespace Test\Controller; use Chert\Annotation\Route; use Chert\Annotation\Value; use Symfony\Component\HttpFoundation\JsonResponse; /** * @Route(path="/test") */ class TestController { /** * @Route(path="/index/{id}",methods={"GET"}, name="test.index") * @Value(variable="id",default="1") */ function index($id) { return new JsonResponse($id); } }
License
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-01-08