1
votes

In this URL: http://siteName/html/test

I want to catch test, of course inside the route. This works great:

Route::get('test', function()
{
    return Route::getCurrentRoute()->getPath();
}); 

But I want to access the path outside of any route and in my route.php file like this:

// routes.php
return Route::getCurrentRoute()->getPath();
Route::get('test', function()
{
    ...
});
1
May be that you have to write some lines. But if you request help, you should tell us what you want to archive. If nobody understands where your problem is, nobody can provide help.Pᴇʜ

1 Answers

4
votes

In case you try to catch all routes. Add this as your last route.

Route::any('{all}', function($uri)
{
    return Route::getCurrentRoute()->getPath();
})->where('all', '.*');