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

Drfraker's avatar

Help with laravel Forge and Way Generators Error

When I run composer install I get the following error. I think it is from an artisan command that is running after the composer install. Artisan thinks it is running on a local env. In my deploy script I have to add the --env="production" flag at the end of artisan commands or I get this error there too. In my config/local/app.php I have the WayGeneratorsServiceProvider referenced, but in config/app.php it is not referenced. What do I need to do to get this error to stop showing up?

forge@Quickernotes:~/quickernotes.com$ composer install --no-dev -vvv
Reading ./composer.json
Loading config file ./composer.json
Executing command (CWD): git describe --exact-match --tags
Executing command (CWD): git branch --no-color --no-abbrev -v
Failed to initialize global composer: Composer could not find the config file: /home/forge/.composer/composer.json
To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section
Reading ./composer.lock
Loading composer repositories with package information
Installing dependencies from lock file
Reading ./composer.lock
Nothing to install or update
Generating autoload files
Executing command (CWD): php artisan optimize
PHP Fatal error:  Class 'Way\Generators\GeneratorsServiceProvider' not found in /home/forge/quickernotes.com/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 157
PHP Stack trace:
PHP   1. {main}() /home/forge/quickernotes.com/artisan:0
PHP   2. require_once() /home/forge/quickernotes.com/artisan:30
PHP   3. require() /home/forge/quickernotes.com/bootstrap/start.php:58
PHP   4. Illuminate\Foundation\ProviderRepository->load() /home/forge/quickernotes.com/vendor/laravel/framework/src/Illuminate/Foundation/start.php:210
PHP   5. Illuminate\Foundation\ProviderRepository->compileManifest() /home/forge/quickernotes.com/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:57
PHP   6. Illuminate\Foundation\ProviderRepository->createProvider() /home/forge/quickernotes.com/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:121
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'Way\\Generators\\GeneratorsServiceProvider' not found","file":"\/home\/forge\/quickernotes.com\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/ProviderRepository.php","line":157}}Script php artisan optimize handling the post-install-cmd event returned with an error



  [RuntimeException]
  Error Output: PHP Fatal error:  Class 'Way\Generators\GeneratorsServiceProvider' not found in /home/forge/quickernotes.com/vendor/laravel/framework/src/Illuminate/F
  oundation/ProviderRepository.php on line 157
  PHP Stack trace:
  PHP   1. {main}() /home/forge/quickernotes.com/artisan:0
  PHP   2. require_once() /home/forge/quickernotes.com/artisan:30
  PHP   3. require() /home/forge/quickernotes.com/bootstrap/start.php:58
  PHP   4. Illuminate\Foundation\ProviderRepository->load() /home/forge/quickernotes.com/vendor/laravel/framework/src/Illuminate/Foundation/start.php:210
  PHP   5. Illuminate\Foundation\ProviderRepository->compileManifest() /home/forge/quickernotes.com/vendor/laravel/framework/src/Illuminate/Foundation/ProviderReposit
  ory.php:57
  PHP   6. Illuminate\Foundation\ProviderRepository->createProvider() /home/forge/quickernotes.com/vendor/laravel/framework/src/Illuminate/Foundation/ProviderReposito
  ry.php:121



Exception trace:
 () at phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:185
 Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:120
 Composer\EventDispatcher\EventDispatcher->dispatchCommandEvent() at phar:///usr/local/bin/composer/src/Composer/Installer.php:336
 Composer\Installer->run() at phar:///usr/local/bin/composer/src/Composer/Command/InstallCommand.php:127
 Composer\Command\InstallCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:252
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:874
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:195
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:146
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:126
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:83
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:43
 require() at /usr/local/bin/composer:25


install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [--ignore-platform-reqs] [packages1] ... [packagesN]
0 likes
3 replies
bashy's avatar

What does your composer.json file look like?

1 like
Drfraker's avatar

I think that's it! It is when the post install artisan commands run. How do I get forge to realize that artisan should run in production on the server?

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "require": {
        "laravel/framework": "4.2.*",
        "thefrozenfire/mindbodyapi": "1.0.*@dev",
        "laravel/cashier": "~2.0",
        "venturecraft/revisionable": "1.*"
    },
    "require-dev": {
        "way/generators": "2.*",
        "barryvdh/laravel-ide-helper": "1.*",
        "codeception/codeception": "2.*"
    },
    "autoload": {
        "classmap": [
            "app/commands",
            "app/controllers",
            "app/database/migrations",
            "app/database/seeds"
        ],
        "psr-4": {
            "Quickernotes\\": "app/Quickernotes"
        }
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan optimize"
        ],
        "pre-update-cmd": [
            "php artisan clear-compiled"
        ],
        "post-update-cmd": [
            "php artisan optimize"
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "stable"
}
Drfraker's avatar
Drfraker
OP
Best Answer
Level 28

So in my Forge deploy script I set composer install --no-dev --no-scripts then I do php artisan optimize --env="production". That seems to have solved the problem. Can't believe it was that simple.

There must be a way to let Artisan know that it is in production mode other than the --env flag.

Here is my Forge deployment script:

cd /home/forge/myapp.com
git pull origin master
composer install --no-dev --no-scripts
php artisan optimize --env="production"
php artisan migrate --force --env="production"

Please or to participate in this conversation.