Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

matsrom's avatar

Class not found on producction

Hi! I've seen many posts like this but none of them helped. The application works on my windows pc bot not on the linux server. My error is: Class "app\enums\Departments" not found

The file exists on the linux server under "app/enums/Departments.php". In development I was using "App\Enums\Departments" and worked but after this error, I changed it to "app\enums\Departments" I've cleared cache and run composer dump-autoload but the error persists.

Any clue?

This is the Department code:

<?php

namespace App\Enums;

enum Departments: int
{

    case IT = 1; 
    case Adminisracion = 2; 
    case IDi = 3; 
    case Food = 4;
    case ESG = 5;
    case Calidad = 6;

    public function label(): string
    {
        return match($this) {
            self::IT => 'IT',
            self::Adminisracion => 'Adminisración',
            self::IDi => 'IDi',
            self::Food => 'Food',
            self::ESG => 'ESG',
            self::Calidad => 'Calidad',
        };
    }

}

0 likes
3 replies
tykus's avatar
tykus
Best Answer
Level 104

It is a problem of playing fast and loose with your casing; Linux is case-sensitive and this matters unlike on a Windows host.

If the file is located in app/enums/Departments.php, then the namespace should be:

namespace App\enums;

However, by convention the directory would be app/Enums, so your changing the directory (and using the existing namespace would be more acceptable).

Aside, the reason app (directory) is different is because it is explicitly mapped to App (namespace) in your composer.json file.

2 likes
matsrom's avatar

@tykus I got it working naming like this: path: app/enums/Department namespace: namespace App\enums; class call: \App\enums\Departments::cases() I understand its because of linux case sensitivity. But why does the namespace and the class call need to have App in caps while the path is not in caps? It is confusing!

tykus's avatar

@matsrom I explained that already....

the reason app (directory) is different is because it is explicitly mapped to App (namespace) in your composer.json file

Really, try to work to PHP and Laravel's conventions, i.e. the file app/Enums/Departments.php is fully qualified as a PHP enum:

App\Enums\Departments

Please or to participate in this conversation.