I cannot bind the "contact" route to the "contact" method which is existing in the "TestController.php" controller
Asked
Active
Viewed 108 times
0
-
Can you provide your routes in your `web.php` ? – Peppermintology May 29 '21 at 21:06
-
yes i did but that doesn't work – Touba Djebli May 29 '21 at 21:09
-
Huh? I mean please add the code for your routes to your question. – Peppermintology May 29 '21 at 21:10
-
– Touba Djebli May 29 '21 at 21:11
-
Did you see here before? https://stackoverflow.com/questions/63807930/target-class-controller-does-not-exist-laravel-8 – ParisaN May 30 '21 at 06:32
3 Answers
1
You don't need to include the file extension when you define routes, so your route should be:
Route::get('/contact','TestController@contact');
Then make sure you have a controller with that name in your controller directory:
app/Http/Controllers/TestController.php
namespace App\Http\Controllers
class TestController extends Controller
{
public function contact()
{
// your code
}
}
You can see a working demo here.

Peppermintology
- 9,343
- 3
- 27
- 51
-
@ToubaDjebli I suspect you have overlooked something then. Do you get the same error or different? – Peppermintology May 29 '21 at 21:38
-
the same ! i am working with a video tutorial and it doesn't get the same result as mine – Touba Djebli May 29 '21 at 22:06
-
@ToubaDjebli I added a working demo link to my answer. Check things like capitlization of your routes and class names, they need to match. Also check namespaces match. – Peppermintology May 29 '21 at 22:07