All Laravel routes are defined in your route files, which are located in the routes directory. These files are automatically loaded by your application's App\Providers\RouteServiceProvider . The routes/web.php file defines routes that are for your web interface.
In Laravel, the routes/web. php and the routes/api. php are the files that you define routes for web and api respectively.
This 'routes.php' file was located in \app\Http in the older versions.
In the newer version, Laravel 5.3, we have a folder named 'routes', where we can find the following files:
For this new version, the routes for your controllers, you can put inside web.php file
See the documentation about routing here
https://laravel.com/docs/5.3/routing#basic-routing
The video lesson you are watching may be outdated.
In the Latest Laravel they have removed common routes.php where as they have added different route files to better manage your application routes.
There is
routes/web.php : routes file which works similar to routes.php file where you can have your routes and all the POST routes in web.php file will be validated for the CSRF Token similar to normal Laravel Post route.
routes/api.php : routes file where you can have your Application's API routes, the URL will be example.com/api/ Eg. If you have route getUsers then the API URL will be example.com/api/getUsers. The most important thing to notice is POST requests to an API url will not be validated for CSRF Token.
routes/console.php : routes file where you can define your Artisan commands which you can run from Laravel Artisan CLI.
Laravel new version don't have routes.php
It has
1.web.php To create Web routes
2.api.php if you are using front (js) framework then write routes here
3.console.php the console.php used for console commands and interaction with commands
@Geraldo has answered it well but still something more you can learn-
In Laravel newer version, old types of routes.php file has deleted.
Why removed:
From Laravel announcement, it has done to give more flexibility to the routes.
Solution:
Now there, a route folder has added and inside that folder there are 4 files.
web.php
-- The previous routes were in this files mainly. Here is where you can register web routes for your application.api.php
-- Here is where you can register API routes for your application.channels.php
-- Here you may register all of the event broadcasting channels that your application supports. console.php
-- For all of the console commands and interaction with commands.See, now it is more flexible for you to add any API and then link it via it's api.php
route file and normal route in web.php
file. Thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With