Laravel Controller Subfolder routing

后端 未结 14 1539
一生所求
一生所求 2020-11-29 16:44

I\'m new to Laravel. To try and keep my app organized I would like to put my controllers into subfolders of the controller folder.

controllers\\
---- folder1         


        
14条回答
  •  隐瞒了意图╮
    2020-11-29 17:26

    In my case I had a prefix that had to be added for each route in the group, otherwise response would be that the UserController class was not found.

    Route::prefix('/user')->group(function() {
        Route::post('/login', [UserController::class, 'login'])->prefix('/user');
        Route::post('/register', [UserController::class, 'register'])->prefix('/user');
    });
    

提交回复
热议问题