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

被刻印的时光 ゝ 提交于 2019-12-06 15:01:13

问题


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

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}
"}

回答1:


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:




回答2:


What really worked for me, was to run composer install, that installed dependencies that I had not yet installed (due to changes made by others by the use of GIT repository).



来源:https://stackoverflow.com/questions/52716203/laravel-lumen-framework5-7-and-flipbox-lumen-generator5-6-class-not-fou

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!