rootlogin/jsrouting-provider
最新稳定版本:v1.0.1
Composer 安装命令:
composer require rootlogin/jsrouting-provider
包简介
javascript routing provider for the silex framework
关键字:
README 文档
README
The JSRouting Provider is a silex routing provider for javascript, that exposes routes to a javascript file. Then you can generate routes for use with javascript frameworks like AngularJS.
Installation
Add the provider to your composer.json
{
"requires": {
"rootlogin/jsrouting-provider": "~1.0"
}
}
Register the provider in your silex application:
$app->register(new rootLogin\JSRoutingProvider\Provider\SilexJSRoutingServiceProvider(), array(
"jsrouting.base_url" => "/",
"jsrouting.exposed_routes" => array("routeA", "routeB")
));
Set the route option expose to true.
$controllers->get("/hello", function() {
return "hello world"!
})->bind("hello")->getRoute()->setOption("expose",true);
Include and use it in your frontend like this.
<!-- Gets the full router with the routes -->
<script src="{{ path("jsrouting") }}"></script>
<!-- Or if you want only some parts you can get the router and the routes separately -->
<script src="{{ path("jsrouter") }}"></script><!-- Gets only the router -->
<script src="{{ path("jsroutes") }}"></script><!-- Gets only the routes -->
<!-- Get routes like this -->
<script>
console.log(router.generate("routeA"));
console.log(router.generate("routeB", {id: 3}));
</script>
Console
If you want to use the console commands please install at least saxulum/saxulum-console. It will be automatically activated after you registered the provider.
Available Commands
- jsrouting:dump: This dumps the router with the known routes (buggy, ATM);
- jsrouting:dump:router.js: This only dumps the router.js. You need to add the routes manually.
Run the tests
Go to the base directory of the jsrouting-provider. Do a composer install and enter vendor/bin/phpunit.
Run the javascript tests
Do a npm install and enter node_modules/.bin/gulp test. Or if you have installed gulp globally enter gulp test.
Contribution
Pull request are welcome. Or if you can't or want code you can also contribute by opening a ticket if you see something is wrong.
Warning
This project is in early development stages. No warranty if it kills your kittens or starts a nuclear war ;)
统计信息
- 总下载量: 7.48k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2014-12-18