Questions tagged [laravel-routing]

Routing in Laravel Framework's MVC implementation. Laravel is a free, open source PHP web application framework, and it is released under the MIT license.

laravel-routing is a tag suitable for any questions regarding routing in Laravel's MVC implementation, url handling, or any other matter affecting or affected by routing in Laravel.

2207 questions
320
votes
32 answers
306
votes
34 answers

Laravel: How to Get Current Route Name? (v5 ... v7)

In Laravel v4 I was able to get the current route name using... Route::currentRouteName() How can I do it in Laravel v5 and Laravel v6?
Md Rashedul Hoque Bhuiyan
  • 10,151
  • 5
  • 30
  • 42
145
votes
23 answers

Laravel 5 - redirect to HTTPS

Working on my first Laravel 5 project and not sure where or how to place logic to force HTTPS on my app. The clincher here is that there are many domains pointing to the app and only two out of three use SSL (the third is a fallback domain, long…
NightMICU
  • 9,000
  • 30
  • 89
  • 121
111
votes
16 answers

Laravel Controller Subfolder routing

I'm new to Laravel. To try and keep my app organized I would like to put my controllers into subfolders of the controller folder. controllers\ ---- folder1 ---- folder2 I tried to route to a controller, but laravel doesn't find it.…
Tino
  • 3,340
  • 5
  • 44
  • 74
109
votes
13 answers

How to get a list of registered route paths in Laravel?

I was hoping to find a way to create an array with the registered routes paths within Laravel 4. Essentially, I am looking to get a list something like this returned: / /login /join /password I did come across a method Route::getRoutes() which…
Kevin Jung
  • 2,973
  • 7
  • 32
  • 35
107
votes
12 answers

Download files in laravel using Response::download

In Laravel application I'm trying to achieve a button inside view that can allow user to download file without navigating to any other view or route Now I have two issues: (1) below function throwing The file "/public/download/info.pdf" does not…
DPP
  • 12,716
  • 3
  • 49
  • 46
105
votes
19 answers

How Can I Remove “public/index.php” in the Laravel Url Generated?

I need to remove index.php or public/index.php from the generated URL in Laravel; commonly path is localhost/public/index.php/someWordForRoute, It should be something like localhost/someWordForRoute. .htaccess
TuGordoBello
  • 4,350
  • 9
  • 52
  • 78
90
votes
19 answers

My Routes are Returning a 404, How can I Fix Them?

I've just started learning the Laravel framework and I'm having an issue with routing. The only route that's working is the default home route that's attached to Laravel out of the box. I'm using WAMP on Windows and it uses PHP 5.4.3, and Apache…
JasonMortonNZ
  • 3,752
  • 8
  • 34
  • 56
82
votes
7 answers

How to clear Laravel route caching on server

This is regarding route cache on localhost About Localhost I have 2 routes in my route.php file. Both are working fine. No problem in that. I was learning route:clear and route:cache and found a small problem below. if I comment any one route in my…
Pankaj
  • 9,749
  • 32
  • 139
  • 283
79
votes
13 answers

Laravel says "Route not defined"

In my routes.php I have: Route::patch('/preferences/{id}', 'UserController@update'); And in the view file (account/preferences.blade.php) I have: {!! Form::model(Auth::user(), ['method' => 'PATCH', 'route' => '/preferences/' . Auth::user()->id])…
Ben Fransen
  • 10,884
  • 18
  • 76
  • 129
75
votes
6 answers

How to structure a modular app in Laravel 5?

I would like to divide my application in modules. For instance, there would be a "core" modules that contains the basic login functionality, app layout/formatting (CSS etc), user management and a diary. Later on I may create other modules like a…
imperium2335
  • 23,402
  • 38
  • 111
  • 190
73
votes
19 answers

Laravel 4 All Routes Except Home Result in 404 Error

I installed Laravel 4 using Composer and also set up a virtual host. Currently, only the root route is working:
Amit Erandole
  • 11,995
  • 23
  • 65
  • 103
68
votes
5 answers

Laravel 5 Resourceful Routes Plus Middleware

Is it possible to add middleware to all or some items of a resourceful route? For example...
kilrizzy
  • 2,895
  • 6
  • 40
  • 63
57
votes
11 answers

How to route GET and POST for same pattern in Laravel?

Does anyone know of any way in Laravel 4 which combines these 2 lines into one? Route::get('login', 'AuthController@getLogin'); Route::post('login', 'AuthController@postLogin'); So instead of having to write both you only have to write one since…
enchance
  • 29,075
  • 35
  • 87
  • 127
50
votes
10 answers

Set session variable in laravel

I would like to set a variable in the session using laravel this way Session::set('variableName')=$value; but the problem is that I don't know where to put this code, 'cause I would like to set it for one time (when the guest visite the home page…
1
2 3
99 100