Laravel控制器:Illuminate \ Contracts \ Container \ BindingResolutionException目标类[AccountController]不存在

问题描述

错误最可能的原因是什么

Illuminate \ Contracts \ Container \ BindingResolutionException

目标类[AccountController]不存在
http://127.0.0.1:8000/

这是我的 web.PHP 文件

<?PHP

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get("/","AccountController@index");

这是我的 AccountController.PHP 文件

<?PHP

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class AccountController extends Controller
{
    public function index(){
        /* $people = [
            ['name' => 'John Doe','age' => 20],['name' => 'Jane Doe','age' => 10]
        ]; */
        return view('account');
    }
}

我还有 account.blade.PHP 作为我的查看文件

我使用命令-PHP artisan make:Controller AccountController-

创建了控制器文件

运行PHP artisan route:list时出现以下错误

 Illuminate\Contracts\Container\BindingResolutionException 

  Target class [AccountController] does not exist.

  at E:\...\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.",$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   E:\...\vendor\laravel\framework\src\Illuminate\Container\Container.PHP:809
      ReflectionException::("Class AccountController does not exist")

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)