Troubleshooting Composer Dump-Autoload Issues in Sage 10 Deployment

Hi everybody,

Currently we are working on a project running on sage 10. When deploying to one of our servers, we are getting Undefined variable error messages. We’ve tried to find the issue, if we run composer dump-autoload, the issue seems to be solved. But each time we deploy, the error comes back again. It looks like the variables inside of our composers are not getting created.

We are making use of the Roots\Acorn\ComposerScripts::postAutoloadDump, and the correct markup for our composer (protected static $views and public function with). Does anyone have experience with this problem and knows how to fix it?


did you add this in Acorn ?

We also recommend adding Acorn’s postAutoloadDump function to Composer’s post-autoload-dump event in the scripts section of composer.json:

"scripts": {
  "post-autoload-dump": [

Hi Igor,

Yes, correct.

What is your deploy process?

                  - step:
                      name: Install Composer dependencies
                      image: composer:2.5
                        - composer
                        - vendor/**
                        - composer install --no-ansi --no-dev --no-interaction --no-progress --optimize-autoloader --no-scripts --classmap-authoritative

                  - step:
                        name: Build yarn
                        image: node:18.15.0
                            - node
                            - yarn
                            - yarn build
                            - public/**

After that, it makes an rsync call to the server. I’ve already tried changing the composer script to - composer install --no-dev with no success.

Try adding wp acorn optimize as a step in your deployment process