ezsystems/templated-uri-bundle

此包已被弃用且不再维护。未建议替代包。

Symfony2 Bundle,提供符合RFC-6570规范的路由器和URL生成器。

安装量: 11,472

依赖者: 0

建议者: 0

安全: 0

星标: 1

关注者: 1

分支: 15

类型:symfony-bundle

3.4.0 2020-03-16 14:19 UTC

This package is auto-updated.

Last update: 2022-05-23 03:35:19 UTC


README

这是一个针对 https://github.com/hautelook/TemplatedUriRouter 库的 Symfony Bundle。 hautelook/TemplatedUriRouter 提供一个符合 RFC-6570 的 Symfony 路由器和URL生成器。

Build Status SensioLabsInsight

安装

假设您已安装 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*}