Laravel 7.0 php artisan route:list返回“目标类[App \ Http \ Controllers \ API \ RolesController]]不存在。”

时间:2020-08-29 18:39:09

标签: php laravel

我正在使用Laravel 7.0,我尝试使用artisan route:list列出我的所有路线,但失败并返回以下内容: Illuminate \ Contracts \ Container \ BindingResolutionException

Target class [App\Http\Controllers\API\RolesController] does not exist.

at C:\xampp\htdocs\Cleanpro\vendor\laravel\framework\src\Illuminate\Container\Container.php:811
807|
808|         try {
809|             $reflector = new ReflectionClass($concrete);
810|         } catch (ReflectionException $e) {
> 811|             throw new BindingResolutionException("Target class [$concrete] does not exist.", 
0, $e);
812|         }
813|
814|         // If the type is not instantiable, the developer is attempting to resolve
815|         // an abstract type such as an Interface or Abstract Class and there is

1   [internal]:0
  Illuminate\Foundation\Console\RouteListCommand::Illuminate\Foundation\Console\{closure} 
(Object(Illuminate\Routing\Route))

2   C:\xampp\htdocs\Cleanpro\vendor\laravel\framework\src\Illuminate\Container\Container.php:809
  ReflectionException::("Class App\Http\Controllers\API\RolesController does not exist")

我的api路由

 Route::post('role','API\RolesController@store');

screenshot of my project architect

3 个答案:

答案 0 :(得分:0)

RolesController.php文件中的名称空间是什么?确保它是App\Http\Controllers\API

namespace App\Http\Controllers\API;

然后,确保文件名RolesController中的类名正确。 确保您没有遗漏任何字母。

答案 1 :(得分:0)

运行此命令

php artisan config:cache 

答案 2 :(得分:0)

尝试运行此命令。

local dss = game:GetService("DataStoreService")
local bands = dss:GetDataStore("banDataStore")

BanPlayer.OnServerEvent:Connect(function(player, playertoban, reason)
    -- check that playertoban is a real player's name
    local bannedPlayer = game.Players:FindFirstChild(playertoban)
    if not bannedPlayer then
        warn("Could not find a player named " .. playertoban)
        return
    end

    -- record their user-id so we can ban them when they rejoin
    local pui = bannedPlayer.UserId
    local success, errormessage = pcall(function()
        bands:SetAsync("Banned-", pui, true)
    end)
    if success then
        print(playertoban .. " Successfully Banned")
    else
        warn(string.format("Failed to ban %s permanently with error : %s", playertoban, errormessage))
    end

    -- remove them from the game
    bannedPlayer:Kick(reason)
end)