I have same controller name(suppose Login.php) in 2 different folders in laravel 8 project. In route it is showing error if I use them in following way.
use App\Http\Controllers\my_controller1\Login;
use App\Http\Controllers\my_controller2\Login;
Error Looks Like
Symfony\Component\ErrorHandler\Error\FatalError
Cannot use App\Http\Controllers\my_controller2\Login as Login because the name is already in use
It will not show error If I use in following way:
use App\Http\Controllers\my_controller1\Login;
and
Route::get('/loginA',[App\Http\Controllers\my_controller2\Login::class,'abc']);
Route::get('/loginB',[Login::class,'abc']);
NOTE: Folder and Controller names are just for assumption.
You'll want to alias one of these if you're using them both in the same file.