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

Halim's avatar
Level 2

Create custom helper in Lumen framework

I try to create a custon helper in Lumen,

1- i create helper class in app folder

2- i add to composer.json in autoload: "files": [ "app/helpers.php" ]

3- i create HelperServiceProvider

4- i register my HelperServiceProvider

$app->register(App\Providers\HelperServiceProvider::class);

5- i RUN COMPOSER DUMP-AUTOLOAD

But : i still get error like :

Warning: require(C:\wamp\www\lumen-api\vendor\composer/../../app/helpers.php): failed to open stream: No such file or directory in

0 likes
3 replies
ejdelmonico's avatar

Use artisan commands to clear all caches and the compiled file.

Halim's avatar
Level 2

php artisan cache:clear

I got the message :

Fatal error : Class 'Memcached' not found

(by the way Im Using Lumen, not Laravel)

Uinta_Ranger's avatar

It worked for me on Lumen 6.3.3 using this pattern AND setting up composer.json the way davielee has shown (below).

"autoload": {
        "files": [
            "app/Library/Helpers/Helpers.php"
        ],
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\": "app/",
            "App\Library\Helpers\": "app/Library/Helpers"
        }
    },

I'm not sure I need both of the entries in composer.json - guess I'll experiment and find out.

Please or to participate in this conversation.