Tuesday, September 26, 2017

Laravel Routes

Hello Developers,

Laravel 5 Implemented routes as sepeately, previously we have in app/Http/routes.php in Laravel 4.

In Laravel 5 maintaining separate directory.

In the newer version, Laravel 5.3, we have a folder named 'routes', where we can find the following files:
  • api.php
  • console.php
  • web.php
For this new version, the routes for your controllers, you can put inside web.php file

Detailed Information:

There is
  1. 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.
  2. 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.
  3. routes/console.php : routes file where you can define your Artisan commands which you can run from Laravel Artisan CLI.


No comments:

Post a Comment

Difference between hook_boot and hook_init Drupal

hook_boot() hook_init() hook_boot() will executes even on cached pages hook_init() will not executes on cached pages hook_boot() is ...