Muhammad Fareed Khan
Muhammad Fareed Khan

Reputation: 29

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

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

Upvotes: 0

Views: 62

Answers (2)

Hesan Naveed
Hesan Naveed

Reputation: 251

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.

Upvotes: 0

Muhammad Anas
Muhammad Anas

Reputation: 108

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']);

Upvotes: 1

Related Questions