在前臺控制器文件上面添加一層后訪問接口報404錯誤
config/route.php
Route::group('/v1/user', function () {
Route::post('/login', [app\controller\v1\UserController::class,'login']); //登錄
});
app/UserController/v1/UserController.php
<?php
namespace app\controller\v1;
class UserController{
public function login(Request $request){
return json(['code' => 0,'msg' =>'登錄成功','data'=>[]]);
}
}
<html>
<head>
<title>404 Not Found - webman</title>
</head>
<body>
<center>
<h1>404 Not Found</h1>
</center>
<hr>
<center>webman</center>
</body>
</html>
關(guān)閉默認路由試試呢
如果你想關(guān)閉默認路由,在配置文件 config/route.php里最后一行加上如下配置:
Route::disableDefaultRoute();