Api difference laravel routing configuration and routing of web Detailed definitions

1, routed through different middleware

Open kerenl.php you can see the difference

 protected $middlewareGroups = [
  'web' => [
   \App\Http\Middleware\EncryptCookies::class,
   \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
   \Illuminate\Session\Middleware\StartSession::class,
   // \Illuminate\Session\Middleware\AuthenticateSession::class,
   \Illuminate\View\Middleware\ShareErrorsFromSession::class,
   \App\Http\Middleware\VerifyCsrfToken::class,
   \Illuminate\Routing\Middleware\SubstituteBindings::class,
  ],
 
  'api' => [
   'throttle:60,1',
   'bindings',
  ],
 ];

2, the path is not the same

In web.php write such a route is

eg:http://quan.cms/backend/admin/add

In api.php wrote routes need to add XXX / api / routing address, the equivalent of adding a layer of api on the basis of web.php

eg:http://quan.cms/api/backend/admin/add

Above this laravel configure routing routing api and web definitions explain the difference is small series to share the entire contents of all of the

Guess you like

Origin www.cnblogs.com/68xi/p/11528119.html