1、路由经过中间件方面不同
打开kerenl.php就可以看到区别
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、路径不一样
在web.php写的路由是这样的
eg:http://quan.cms/backend/admin/add
在api.php写的路由需要加上XXX/api/路由地址,相当于在web.php的基础上加了一层api
eg:http://quan.cms/api/backend/admin/add
以上这篇laravel 配置路由 api和web定义的路由的区别详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持NICE源码。