Class 'Way\Generators\GeneratorsServiceProvider' 未找到

Class 'Way\Generators\GeneratorsServiceProvider' not found

我正在尝试在 Google App Engine Standard 上获得 Laravel 运行。我已经让它在灵活的情况下工作,但需求发生了变化,我们现在需要标准。我使用 PHP 7.2 环境和 Laravel 5.7。部署有效,但在尝试访问页面时,我在日志中收到错误消息:

Symfony\Component\Debug\Exception\FatalThrowableError: Class 'Way\Generators\GeneratorsServiceProvider' not found
at Illuminate\Foundation\Application->register (/srv/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:662)

我在本地的第 662 行至少只是 return new $provider($this);,它似乎没有明确引用生成器包。

那个生成器包似乎是 way/generators 但是当我在本地 composer require way/generators 时,它发出一百万个不同的警告,然后是

> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

In GeneratorsServiceProvider.php line 58:

  Call to undefined method Illuminate\Foundation\Application::share()  


Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

根据我的阅读,Laravel > 5 不需要生成器包,因为它已经包含了它,但出于某种原因,在 GAE 上它试图引用它(在本地它运行良好 artisan serve).我已经尝试了各种作曲家 post 安装命令,但没有任何帮助。

"post-install-cmd": [
            "php artisan cache:clear",
            "php artisan optimize:clear",
            "php artisan config:clear",
            "php artisan config:cache",
            "Illuminate\Foundation\ComposerScripts::postInstall",
            "php artisan optimize",
            "chmod -R 755 bootstrap\/cache"
        ]

正如您在评论中提到的,问题源于使用 xethron/migrations-generator (https://github.com/Xethron/migrations-generator),这需要在 config/app.phpapp/Providers/AppServiceProvider.php 中额外手动设置服务提供商.奇怪的是它的 composer.json 不需要 way/generators,而是包括另一个包,该包也包含 way/generators 的文件 (?)。很奇怪,但解释了为什么事情在 composer install.

上变得一团糟

正如您所做的那样,核对它是一个选项或完成手动设置也可能没问题,尽管 way/generators 适用于 Laravel 的旧版本并且不一定能 100% 工作.