Home > Software engineering >  Laravel new controllers not working after deploy, how i Solve this?
Laravel new controllers not working after deploy, how i Solve this?

Time:04-08

I have a Laravel project and it works good, but I decided to update it and add new features. Since I deployed the project if I try to add new controllers or do and php artisan route:list I always get a 500 error that my class its not found ReflectionException::("Class "AyudaController" does not exist")

This is my web.php

Route::get('ayuda', [AyudaController::class, 'show'])->name('ayuda');

And this is my AyudaController.php

<?php

namespace App\Http\Controllers;
use App\Http\Controllers\Controller;



class AyudaController extends Controller
{
    public function show()
    {
        return view('ayuda');
    }
}

And I have a view ayuda.blade.php

CodePudding user response:

Try to add this to web.php file:

use App\Http\Controllers\AyudaController;

You must import this controller before you can use it.

CodePudding user response:

Every time you must import the classes which you use. in your case you should import AyudaController controller in web.php.

CodePudding user response:

Clear app cache and routing, check that you don't have a typo or case issue with use, names and namespacing. My guess your problem is route caching though.

  • Related