I just want to echo Hello world through Route
Route::get('/user',[addnewcontroller::class, 'getData']);
this is my web.php Route and this is controller
class addnewcontroller extends Controller
{
function getData()
{
echo "My name is hassan";
}
}
whenever i try to execute it say controller doesnt exist, kindly let me know why im facing this error, ive tried many things like clearing caches, code etc
CodePudding user response:
you need to define path of controller in web.php
like this:
use App\Http\Controllers\addnewcontroller;
CodePudding user response:
You must use App\Http\Controllers\addnewcontroller at the top of routes
