ezsystems / templated-uri-bundle
此包已被弃用且不再维护。未建议替代包。
Symfony2 Bundle,提供符合RFC-6570规范的路由器和URL生成器。
3.4.0
2020-03-16 14:19 UTC
Requires
- php: ^5.4|^7.0
- ezsystems/templated-uri-router: ^2.0|^3.1
- symfony/framework-bundle: ^2.8|^3.0|^4.0|^5.0
Requires (Dev)
- phpunit/phpunit: ^4.8.36|^5.0|^6.0|^7.0
Replaces
README
这是一个针对 https://github.com/hautelook/TemplatedUriRouter 库的 Symfony Bundle。 hautelook/TemplatedUriRouter
提供一个符合 RFC-6570 的 Symfony 路由器和URL生成器。
安装
假设您已安装 composer,请运行以下命令
$ composer require hautelook/templated-uri-bundle
现在将此包添加到您的Kernel中
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Hautelook\TemplatedUriBundle\HautelookTemplatedUriBundle(), // ... ); }
如果您使用 Symfony Flex,此包会自动添加到您的 bundles.php
文件中。
用法
该包公开了一个路由服务(hautelook.router.template
),可以生成符合RFC-6570规范的URL。以下是如何使用它的示例
$templateLink = $container->get('hautelook.router.template')->generate('hautelook_demo_route', array( 'page' => '{page}', 'sort' => array('{sort}'), 'filter' => array('{filter}'), ) );
这将生成类似以下链接的链接
/demo?{&page}{&sort*}{&filter*}