此错误最可能的原因是什么
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.", 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 E:\...\vendor\laravel\framework\src\Illuminate\Container\Container.php:809
ReflectionException::("Class AccountController does not exist")