Expose the hautelook/TemplatedUriRouter in a symfony application
PHP
Latest commit abf784f Apr 29, 2016 @muub muub Merge pull request #18 from adrienbrault/patch-1
Fix composer instructions
Permalink
Failed to load latest commit information.
DependencyInjection
Resources/config Remove the scope from the service definition Dec 8, 2015
Tests
.gitignore
.travis.yml
HautelookTemplatedUriBundle.php
README.md
composer.json
phpunit.xml.dist Improve gitignore + travis/phpunit Nov 24, 2012

README.md

Hautelook Templated URI Bundle

Symfony2 Bundle for the https://github.com/hautelook/TemplatedUriRouter library.

Build Status SensioLabsInsight

Installation

Run the following command (assuming you have installed composer.phar or composer binary), or add to your composer.json and run composer install:

$ composer require "hautelook/templated-uri-bundle ~2.0"

Now add the bundle to your Kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Hautelook\TemplatedUriBundle\HautelookTemplatedUriBundle(),
        // ...
    );
}

Usage

The bundle exposes a router service (hautelook.router.template) that will generate RFC-6570 compliant URLs. Here is a sample on how you could use it:

$templateLink = $this->get('hautelook.router.template')->generate('hautelook_demo_route',
    array(
        'page'   => '{page}',
        'sort'   => array('{sort}'),
        'filter' => array('{filter}'),
    )
);

This will produce a link similar to:

/demo?{&page}{&sort%5B%5D*}{&filter%5B%5D*}