PHPackages                             iltar/http-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. iltar/http-bundle

AbandonedArchivedSymfony-bundle[HTTP &amp; Networking](/categories/http)

iltar/http-bundle
=================

Adding extra functionality to Symfony

v1.1.4(8y ago)4020.2k4MITPHPPHP ^5.5||^7.0

Since Aug 19Pushed 4y ago1 watchersCompare

[ Source](https://github.com/linaori/http-bundle)[ Packagist](https://packagist.org/packages/iltar/http-bundle)[ RSS](/packages/iltar-http-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (7)Dependencies (13)Versions (15)Used By (0)

This package is now archived. If you wish to keep using it, please fork it.

http-bundle
===========

[](#http-bundle)

Provides extra HTTP related functionality in Symfony.

Requirements:

- PHP 5.5 or higher, including php 7
- Symfony 2.7 or higher

Recommended installation is via composer: `composer require iltar/http-bundle`.

Router Enhancements
-------------------

[](#router-enhancements)

```
    /**
     * @Route("/profile/{user}/", name="app.view-profile")
     */
    public function viewProfileAction(AppUser $user);
```

Let's say we have a [ParamConverter](http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html)on this route that would nicely convert the `user` parameter of your route to an `AppUser`, but how would you generate the route for this action? Sadly you still need a scalar as parameter for `Router::generate()`:

```
$router->generate('app.view-profile', ['user' => $user->getId()]);
```

Okay, not really a big problem, but we're passing an id to a parameter which you would expect to have an `AppUser` if you look at the action. Another problem is that if you want to change the argument passed along, you will have to update every single usage of this URL. A decent IDE can get around this issue, but wait! What about your twig templates?

```
{{ path('app.view-profile', { 'user': user.id }) }}
{{ path('app.view-profile', { 'user': user.getid }) }}
{{ path('app.view-profile', { 'user': user.getId() }) }}
{{ path('app.view-profile', { 'user': user[id] }) }}

{# I think you see where I'm going at #}
```

How nice would it be if you could just pass your user object along?

```
$router->generate('app.view-profile', ['user' => $user]);
```

> The router decorator is provided to make it easier to resolve arguments required for route generation. They work like a reversed [ParamConverter](http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html).

#### A quick Example

[](#a-quick-example)

You need to do two things to make this work:

- create a resolver
- write a service definition for it and tag it accordingly

```
