Home > Blockchain >  Although I created the route correctly But when I try to show the page It gives me an error page not
Although I created the route correctly But when I try to show the page It gives me an error page not

Time:08-24

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.

  1. See if your routes aren't cached. Run php artisan route:clear in order to clear the cached routes.
  2. Where have you defined the route? If it's in the web.php file then, your actual url should be: http://localhost:8000/text.
  3. If it's in the api.php file then, your url should be: http://localhost:8000/api/text.
  • Related