Skip to content
Advertisement

Laravel 8 Controller does not exist, namespace is in routes and problem only exists on an apache webserver but works locally

I’m currently trying to get a small laravel 8 project to work on an apache webserver. It works on localhost with artisan and in xampp, however doing exactly the same on the apache webserver I have access to doesn’t work.

This is my Controller with namespace and its name:

namespace with Controller name

These are the functions I’m trying to use

   function showProfile()
    {
        return view("accountinfo");
    }
   function startup()
    {
        return view("landing");
    }
   function courseOverview()
    {
        return view("courses");
    }

This is the namespace in routes which should work as shown in other answers to similar posts as well as the routes I’m trying to use.

Route namespace

routes

This is the only controller that does not work on the server. I am using Laravel Breeze for basic authentication and those routes and controllers work fine. I tried adding and removing the namespace as well as the following commands that “worked” for other people:

php artisan clear-compiled 

php artisan optimize:clear

composer dump-autoload 

Earlier I had permission issues that I managed to resolve for that particular error. Could this type of error arise from a similar issue? Permissions however are the same for all Auth controllers as well as my KnowledgeController. Let me know if you need more information or code from my end.

Here you can find the stack trace

Thanks in advance!

Advertisement

Answer

Namespaces seem to be case sensitive for the webserver, and I didn’t manage to catch the typo. Local artisan and xampp seem to be able to handle it even though it’s not correct. The apache webserver had a problem with it. It’s supposed to be

use AppHttpControllersKnowledgeController;
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement