Php Laravel路由:返回列表错误

Php Laravel路由:返回列表错误,php,laravel,routes,Php,Laravel,Routes,当我尝试运行route:list时,出现以下错误: PHP Fatal error: Cannot declare class App\Http\Controllers\UserController, because the name is already in use in /home/vagrant/Code/nomads/app/Http/Controllers/Admin/UserController.php on line 0 [Symfony\Component\Debug\

当我尝试运行
route:list
时,出现以下错误:

PHP Fatal error:  Cannot declare class App\Http\Controllers\UserController, 
because the name is already in use in 
/home/vagrant/Code/nomads/app/Http/Controllers/Admin/UserController.php on line 0

[Symfony\Component\Debug\Exception\FatalErrorException]
Cannot declare class App\Http\Controllers\UserController, because the name is already in use
我在控制器下有
UserController
,还有
Admin
文件夹,其中有另一个
UserController


我也在使用包,但我已经覆盖了包路由,并且正在使用Laravels本机路由。

如果您真的想这样做,请将admin/UserController更改为AdminController并扩展类UserController

use App\Http\Controllers\UserController;

class AdminController extends UserController 
{

您可以像下面那样在使用名称空间别名(“as”)的过程中使用它

使用App\Http\Controllers\Admin\UserController作为AdminUserController


重命名其中一个用户控制器或使用名称空间。