This is my function in MemberController
public function text(){
return "hello";
}
This is my route
Route::get('/text',[MemberController::class,'text']);
So,basically its unable to read new route that i created. Thanks in advance
CodePudding user response:
Hope you're using laravel 8 and above follwoing should be your controller code (MemberController.php)
<?php
namespace App\Http\Controllers;
class MemberController extends Controller{
public function text(){
return "hello";
}
}
and this should be your route code (web.php)
<?php
use App\Http\Controllers\MemberController;
Route::get('/text',[MemberController::class,'text']);
CodePudding user response:
Code you have provided is not enough, though you can check following things.
- See if your routes aren't cached. Run
php artisan route:clear
in order to clear the cached routes. - Where have you defined the route? If it's in the
web.php
file then, your actual url should be: http://localhost:8000/text. - If it's in the
api.php
file then, your url should be: http://localhost:8000/api/text.