Target class [App\Http\Controllers\UsersController] does not exist.
possible that your route file (web.php) forgot to group or prefix the "Admin\" for UsersController....
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
When executing a request, the artisan route: the list pops up such an error.
Everything was done according to the installation instructions, but I can not add permissions and users through the admin panel.
Illuminate\Contracts\Container\BindingResolutionException
Target class [App\Http\Controllers\UsersController] does not exist.
at C:\htdocs\www\rpc\vendor\laravel\framework\src\Illuminate\Container\Container.php:807
803|
804| try {
805| $reflector = new ReflectionClass($concrete);
806| } catch (ReflectionException $e) {
807| throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
808| }
809|
810| // If the type is not instantiable, the developer is attempting to resolve
811| // 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:\htdocs\www\rpc\vendor\laravel\framework\src\Illuminate\Container\Container.php:805
ReflectionException::("Class App\Http\Controllers\UsersController does not exist")
PS C:\htdocs\www\rpc>
UserController.php
<?php
namespace App\Http\Controllers\Admin;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\User;
use App\Role;
use App\Permission;
class UsersController extends Controller
{
//
public function __construct()
{
//$this->middleware('role:users');
}
// Index Page for Users
public function index()
{
$users = User::paginate(10);
$params = [
'title' => 'Users Listing',
'users' => $users,
];
return view('admin.users.users_list')->with($params);
}
// Create User Page
public function create()
{
$roles = Role::all();
$params = [
'title' => 'Create User',
'roles' => $roles,
];
return view('admin.users.users_create')->with($params);
}
// Store New User
public function store(Request $request)
{
$this->validate($request, [
'name' => 'required',
'email' => 'required|unique:users',
'password' => 'required',
]);
$user = User::create([
'name' => $request->input('name'),
'email' => $request->input('email'),
'password' => bcrypt($request->input('password')),
]);
$role = Role::find($request->input('role_id'));
$user->attachRole($role);
return redirect()->route('users.index')->with('success', "The user <strong>$user->name</strong> has successfully been created.");
}
// Delete Confirmation Page
public function show($id)
{
try {
$user = User::findOrFail($id);
$params = [
'title' => 'Confirm Delete Record',
'user' => $user,
];
return view('admin.users.users_delete')->with($params);
} catch (ModelNotFoundException $ex) {
if ($ex instanceof ModelNotFoundException) {
return response()->view('errors.' . '404');
}
}
}
// Editing User Information Page
public function edit($id)
{
try {
$user = User::findOrFail($id);
//$roles = Role::all();
$roles = Role::with('permissions')->get();
$permissions = Permission::all();
$params = [
'title' => 'Edit User',
'user' => $user,
'roles' => $roles,
'permissions' => $permissions,
];
return view('admin.users.users_edit')->with($params);
} catch (ModelNotFoundException $ex) {
if ($ex instanceof ModelNotFoundException) {
return response()->view('errors.' . '404');
}
}
}
// Update User Information to DB
public function update(Request $request, $id)
{
try {
$user = User::findOrFail($id);
$this->validate($request, [
'name' => 'required',
'email' => 'required|email|unique:users,email,' . $id,
]);
$user->name = $request->input('name');
$user->email = $request->input('email');
$user->save();
// Update role of the user
$roles = $user->roles;
foreach ($roles as $key => $value) {
$user->detachRole($value);
}
$role = Role::find($request->input('role_id'));
$user->attachRole($role);
// Update permission of the user
//$permission = Permission::find($request->input('permission_id'));
//$user->attachPermission($permission);
return redirect()->route('users.index')->with('success', "The user <strong>$user->name</strong> has successfully been updated.");
} catch (ModelNotFoundException $ex) {
if ($ex instanceof ModelNotFoundException) {
return response()->view('errors.' . '404');
}
}
}
// Remove User from DB with detaching Role
public function destroy($id)
{
try {
$user = User::findOrFail($id);
// Detach from Role
$roles = $user->roles;
foreach ($roles as $key => $value) {
$user->detachRole($value);
}
$user->delete();
return redirect()->route('users.index')->with('success', "The user <strong>$user->name</strong> has successfully been archived.");
} catch (ModelNotFoundException $ex) {
if ($ex instanceof ModelNotFoundException) {
return response()->view('errors.' . '404');
}
}
}
}
User.php
<?php
namespace App;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laratrust\Traits\LaratrustUserTrait;
class User extends Authenticatable
{
use LaratrustUserTrait;
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}
Please or to participate in this conversation.