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

Pieter-Jan's avatar

Helper file not registering

Hello, I am trying to set up a bitwise authentication. For this I am trying to create a Helper file (app/Helpers/RoleHelper.php). So that I can check the bits to the defined roles. Sadly enough the file / namespace is not found.

RoleHelper.php


namespace App\Helpers;

class RoleHelper
{
    const NONE = 0b0000;
    const USER = 0b0001;
    const EMPLOYEE = 0b0010;
    const ADMIN = 0b0100;

    const EMPLOYEE_USER = self::USER | self::EMPLOYEE; // 0011
    const ADMIN_ALL = self::USER | self::EMPLOYEE | self::ADMIN; // 0111
}

Composer.json

"autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/",
            "App\\": "app/"
			// Tried this to in the past "App\\Helpers\\": "app/Helpers/"																						
        },
        "files": [
            "app/Helpers/RoleHelper.php"
        ]
    },

I did the "composer dump-autoload"

I tried use App\Helpers\RoleHelper; I tried adding the \App\Helpers\RoleHelper::EMPLOYEE directly.

I realy am at a loss here

0 likes
4 replies
Snapey's avatar

whats the exact name of the folder containing your class

Snapey's avatar

as you have made it a class in the app namespace, you dont need the files entry in composer.json

Pieter-Jan's avatar

@Snapey the folder name is app/Helpers

Files is residual json of my testing.

tykus's avatar

Your composer.json does not need to autoload the class from files since it is already in the App namespace, so you should remove this:

"files": [
  "app/Helpers/RoleHelper.php"
]

Just make sure there is no typo in the path, namespace and class name.

Please or to participate in this conversation.