Search code examples
phplaravelgoogle-app-enginecomposer-phpgoogle-app-engine-php

Class 'Way\Generators\GeneratorsServiceProvider' not found


I’m attempting to get Laravel running on Google App Engine Standard. I already had it working on flexible, but requirements changed and we need standard now. I’m using the PHP 7.2 environment with Laravel 5.7. The deploy works but when trying to visit a page, I just get an error in the logs:

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)

Line 662 for me locally at least is just return new $provider($this); which doesn’t seem to be explicitly referencing the generators package.

That generator package appears to be way/generators but when I do composer require way/generators locally, it spits out a million different warnings followed by

> 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

From what I’ve read Laravel > 5 does not need the generators package as it already has it included but for some reason on GAE it’s trying to reference it (locally it runs fine with artisan serve). I’ve tried all sorts of composer post install commands, but nothing has helped.

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

Solution

  • As you mentioned in the comments, the issue stems from using xethron/migrations-generator (https://github.com/Xethron/migrations-generator) which requires additional manual setup of service providers in either config/app.php or app/Providers/AppServiceProvider.php. The strange thing is that its composer.json does not require way/generators, but rather includes another package which also contains the files (?) for way/generators. Very strange, but explains why things are getting messy upon a composer install.

    As you've done, nuking it is an option or completing the manual setup may also okay, although way/generators is for older versions of Laravel and cannot necessarily be expected to work 100%.