欢迎各位兄弟 发布技术文章
这里的技术是共享的
# php artisan make:controller Front/ProductController
报如下的错
[ReflectionException] Class App\Http\Controllers\Front\ProductController does not exist
下面的红色的可以看一下
I added the "User" controller through
php artisan make:controller User
and hit enter before I realized I didn't add the word "Controller" to the end.
I changed it in the file name to "UserController.php", and in web.php, but I still receive the error:
ReflectionException Class App\Http\Controllers\User does not exist
I'm not sure where else to look. I don't see where I have referenced the Controller with just "User".
I receive the error when I visit
是因为 在 php artisan make:controller 之前 在 routes.php 中己经定义了
UserController 这个控制器,所以 才会报 ReflectionException (反射异常)
My code in web.php is: Route::get('users/{user}', 'UserController@edit');
My UserController is:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Auth;
class UserController extends Controller
{
public function edit(User $user)
{
$user = Auth::user();
return view('user.edit', compact('user'));
}
public function update(User $user)
{
$user->name = request('name');
$user->email = request('email');
$user->save();
return view('home', ['user' => $user]);
}
}
Thanks.