I am using the laravel framework. If I have the following route:
Route::get('/test/{param}', array('before'=>'test_filter', 'SomeController@anyAction'));
And this filter:
Route::filter('test_filter', function() {
$param = [Get the parameter from the url];
return "The value is $param";
});
How can I pass parameters to the filter so that when visiting /test/foobar I would get a page saying: "The value is foobar"?
Filters can be passed parameters, like the Route object or the Request:
Specifying Filter Parameters
Above example is taken from the docs: http://laravel.com/docs/routing#route-filters
Once you're inside the closure, you take the parameter from the
$route
:Alternatively, I believe you can just fetch the segment you need (not tested but should work):