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?

Regards,
Klaas

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": [
    "Roots\\Acorn\\ComposerScripts::postAutoloadDump"
  ]
}

Hi Igor,

Yes, correct.

What is your deploy process?

2 Likes
                  - step:
                      name: Install Composer dependencies
                      image: composer:2.5
                      caches:
                        - composer
                      artifacts:
                        - vendor/**
                      script:
                        - 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
                        caches:
                            - node
                        script:
                            - yarn
                            - yarn build
                        artifacts:
                            - 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