optional parameters does not mean you can just bang two slashes next to each other and consider that an omitted parameter.
I think you are being unrealistic expecting that to work.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Can anyone please verify this finding, which I consider a bug in Laravel 5.4: in my web.php file I have a route ...
Route::get('test/{parentId?}/{name?}','myController@test');
The controller looks like so:
class myController extends Controller
{
//
public function test($parentId = 'default parentid',$name = "default name") {
return "parentid: [$parentId] name: [$name]";
}
The webserver (artisan serve) is running on localhost:11111 and this is what I get if I test the route parameters:
localhost:111111/test: parentid: [default parentid] name: [default name]
localhost:111111/test/pid: parentid: [pid] name: [default name]
localhost:111111/test/pid/nme: parentid: [pid] name: [nme]
localhost:111111/test/pid/: parentid: [pid] name: [default name]
localhost:111111/test//nme: (404) NotFoundHttpException (RouteCollection.php)
According to the debugger web.php is called, and the REQUEST_URL property does correctly read: /test//nme. Seems like the default parameter mechanism fails, if I omit the 1st parameter, but provide the second.
Is this a known issue, any workaround?
Armin.
Please or to participate in this conversation.