如何解决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 举报,一经查实,本站将立刻删除。