Search code examples
lumen

laravel/lumen-framework:"5.7.*" and flipbox/lumen-generator:"^5.6" Class Not Found


I think this is related to composer autoload not detecting packages outside laravel/lumen-framework/src

Is my above assumption to the below problem correct? Shall I include psr-4 key inside "autoload-dev" nested object?

I really appreciate your help.

Thanks.

Below is Error Exception, composer.json snippet and Stack Trace Logs

Exception

Below composer.json

        {
        ...
        "autoload": {
            "classmap": [
                "database/seeds",
                "database/factories"
            ],
            "psr-4": {
                "App\\": "app/"
            }
        },
        "autoload-dev": {
            "classmap": [
                "tests/"
            ]
        },
        ...
    }

Below is the stack trace log found under storage/lumen.log

[2018-10-09 07:51:53] local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: 
Class '\FlipBox\LumenGenerator\LumenGeneratorServiceProvider' not found in 
/var/www/vendor/laravel/lumen-framework/src/Application.php:183
Stack trace:
#0 /var/www/bootstrap/app.php(86): Laravel\Lumen\Application->register('\\FlipBox\\LumenG...')
#1 /var/www/public/index.php(14): require('/var/www/bootst...')
#2 {main} {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): 
Class '\\FlipBox\\LumenGenerator\\LumenGeneratorServiceProvider' not 
found at /var/www/vendor/laravel/lumen-framework/src/Application.php:183)
[stacktrace]
#0 /var/www/bootstrap/app.php(86): Laravel\\Lumen\\Application->register('\\\\FlipBox\\\\LumenG...')
#1 /var/www/public/index.php(14): require('/var/www/bootst...')
#2 {main}
"}

Solution

  • It was really a stupid mistake, after debugging and going to the north pole back and forth. I figured out that I had the class namespace referenced wrongly so instead of using below:

    if ($app->environment() !== 'production') {
        $app->register(FlipBox\LumenGenerator\LumenGeneratorServiceProvider::class);
    }
    

    I should have used small letter b instead of B so the below works:

    if ($app->environment() !== 'production') {
        $app->register(Flipbox\LumenGenerator\LumenGeneratorServiceProvider::class);
    }
    

    Then doing php artisan list you will get all the make:* goodies:

    enter image description here