fdevs/export-routing
最新稳定版本:0.2.1
Composer 安装命令:
composer require fdevs/export-routing
包简介
关键字:
README 文档
README
export symfony routing to js/json
If you use with js, you could use npm package fos-routing!
Installation
Export routing uses Composer, please checkout the composer website for more information.
The simple following command will install export-routing into your project. It also add a new
entry in your composer.json and update the composer.lock as well.
composer require fdevs/export-routing
Export your routes
<?php use FDevs\ExportRouting\Normalizer\RouteCollectionNormalizer; use FDevs\ExportRouting\Normalizer\RouteNormalizer; use FDevs\ExportRouting\Normalizer\RouteExtractorNormalizer; use FDevs\ExportRouting\Encoder\JsCallbackEncoder; use FDevs\ExportRouting\RoutesExtractor; use FDevs\ExportRouting\Extractor\ChainExposed; use FDevs\ExportRouting\Extractor\OptionExposed; use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\Encoder\JsonEncoder; $router = ;//get your routes Symfony\Component\Routing\RouterInterface $exposed = new ChainExposed([new OptionExposed()]); $extractor = new RoutesExtractor($router,$exposed); $normalizers = [ new RouteCollectionNormalizer(), new RouteNormalizer(), new RouteExtractorNormalizer(), //your normalizers ]; $encoders = [ new JsCallbackEncoder(), new JsonEncoder(), //your encoders ]; $serializer = new Serializer(normalizers, encoders); echo $serializer->serialize(extractor,'js',['callback' => 'initRouting']);//js with callback echo $serializer->serialize(extractor,'json');//json
Use with Symfony Framework Bundle
- add
FDevs\ExportRouting\FDevsExportRoutingBundleto you kernel
Use command
Create your application with Console Component
###Add Command
// ... $serializer = new Serializer(\**\);//init serializer $extractor = new RoutesExtractor(\**\);//init extractor $application->add(new DumpCommand($serializer,$extractor,'fdevs:dump-routing:dump'));
###Run Command
bin/console fdevs:export-routing:dump
统计信息
- 总下载量: 939
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-04