Diff between web routing and api routing in laravel 5.3

laravel, laravel-5.3, php

Solution

- What does it mean `stateless` in api route ?

It means server doesn't save client 'state' between requests. Here is couple words about REST What exactly is RESTful programming?

- Web routing uses `session state`, `CSRF protection`. Does it mean api routing is not using session state, CSRF protection ?

All is possible but not required. You still can using sessions etc, but this is a REST principles violation.

- Laravel 5.3 uses seperate `web` and `api` routing, is there any advantages

It's just for your convenience. In Laravel 5.2 you need specify middleware for routes like ['web'] or ['api'] but it doesn't required anymore. In 5.3 routes stored in separated files and specify routes middleware not required.

Problem

I read many post regarding new concept about api routing. I understood that api routing is used for mobile platforms but is there code level difference between them In `RouteServiceProvider` i can see ``` /** * Define the "web" routes for the application. * * These routes all receive session state, CSRF protection, etc. * * @return void */ protected function mapWebRoutes() { Route::group([ 'middleware' => 'web', 'namespace' => $this->namespace, ], function ($router) { require base_path('routes/web.php'); }); } /** * Define the "api" routes for the application. * * These routes are typically stateless. * * @return void */ protected function mapApiRoutes() { Route::group([ 'middleware' => 'api', 'namespace' => $this->namespace, 'prefix' => 'api', ], function ($router) { require base_path('routes/api.php'); }); } ``` As per this web route uses These routes all receive session state, CSRF protection, etc. api route These routes are typically stateless. My question is What does it mean `stateless` in api route ? Web routing uses `session state`, `CSRF protection`. Does it mean api routing is not using session state, CSRF protection ? Laravel 5.3 uses seperate `web` and `api` routing, is there any advantages ?

Original source

Related problems