I wanna redirect to my controller instead of a view but it says: "Target class [app/Http/Controllers/MyFirstController] does not exist. "
here is the code (web.php file):
//just a view
Route::get('/', function () {
return view('index');
});
//just a view
Route::get('/final', function () {
return view('welcome');
});
//the controller is interested in
Route::get('/hello-controller', 'app/Http/Controllers/MyFirstController@index');
Controller code (app/Http/controllers/MyFirstController.php) :
<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
class MyFirstController extends Controller
{
public function index(){
return "viva";
}
}
additional information:
Laravel Framework version: 8.83.17
PHP version : PHP 7.4.29
2
Answers
try to clear cache your controller by using
and also maybe u should use
The namespace is not correct: Capital A for App and use
instead of
/
or even better :