Skip to content

Conversation

@meowcakes
Copy link
Contributor

When binding a parameter in a route the binding closure is called when
generating a URL using UrlGenerator. This certainly doesn't seem like intended behaviour as the resolved binding is never even put into the generated URL.

@JoostK
Copy link
Contributor

JoostK commented Feb 4, 2013

You don't have to cache the compiled route yourself, Symfony does it already for us.

@meowcakes
Copy link
Contributor Author

Whoops, didn't realise that.

When binding a variable in a route the bind closure is called when
generating a URL using UrlGenerator
symfony already does it for us
@taylorotwell
Copy link
Member

Can you give a little more detail on this? Maybe a code example of how I can recreate this?

@jasonlewis
Copy link
Contributor

Taylor, consider the following example.

Route::bind('username', function($username, $route)
{
    var_dump('Running username binding.');
    return strtoupper($username);
});

Route::get('{username}', ['as' => 'profile', function($username)
{
    return $username;
}]);

die(URL::route('profile', ['jason']));

The closure for the binding is still fired even when generating a URL. This
seems pointless.
On Feb 5, 2013 9:47 AM, "Taylor Otwell" [email protected] wrote:

Can you give a little more detail on this? Maybe a code example of how I
can recreate this?


Reply to this email directly or view it on GitHubhttps://github.com//pull/254#issuecomment-13104388.

taylorotwell added a commit that referenced this pull request Feb 5, 2013
BUG: using UrlGenerator with routes that have bound parameters
@taylorotwell taylorotwell merged commit 790c68a into laravel:master Feb 5, 2013
@taylorotwell
Copy link
Member

Thanks

joelharkes added a commit to joelharkes/framework_old that referenced this pull request Mar 7, 2019
Bugfix tutorial + Small bugfix to calendar - minimal date value
gonzalom pushed a commit to Hydrane/tmp-laravel-framework that referenced this pull request Oct 12, 2023
`Laravel\Lumen\Http\ResponseFactory` doesn't take any argument on construct, and standardise app() usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants