Skip to content

Ability to skip dumping autoloader #676

@Wirone

Description

@Wirone

Verification

  • I have updated Composer to the most recent stable release (composer self-update)
  • I have updated Composer Patches to the most recent stable release (composer update cweagans/composer-patches)
  • I am using one of the supported PHP versions (8.0+)
  • I have searched existing issues and discussions for my idea.

Is your feature request related to a problem?

I am working on introducing this package into our app's build flow, and it basically works (thanks!), but there is one small issue - it's not possible to skip dumping autoloader after applying patches. Our scenario is related to Docker build, where composer install --no-plugins --no-autoloader --no-scripts (...) && composer patches-repatch --no-scripts is executed in the interim Docker build layer with Github token mounted as secret for Composer. This layer has only composer.* files + patches, and does not contain whole application, so autoloading can't be done at this point. On the other hand, I can't run patches-repatch later, where composer dump-autoload is done explicitly, because we don't have secret mounted at that point of multi-stage build.

This leads to this:

#15 15.30   - Patching foo/bar
#15 15.60 Generating autoload files
#15 15.80 140 packages you are using are looking for funding.
#15 15.80 Use the `composer fund` command to find out more!
#15 16.03 PHP Warning:  require(/srv/app/vendor/composer/../../app/Helpers/global.php): Failed to open stream: No such file or directory in /srv/app/vendor/composer/autoload_real.php on line 41
#15 16.03 PHP Fatal error:  Uncaught Error: Failed opening required '/srv/app/vendor/composer/../../app/Helpers/global.php' (include_path='.:/usr/local/lib/php') in /srv/app/vendor/composer/autoload_real.php:41
#15 16.03 Stack trace:
#15 16.03 #0 /srv/app/vendor/composer/autoload_real.php(45): ***closure***()
#15 16.03 #1 /srv/app/vendor/autoload.php(22): ComposerAutoloaderInite54b6b9ed6c057483fb34154d1b7002a::getLoader()
#15 16.03 #2 /srv/app/vendor/phpro/grumphp/bin/grumphp(13): require_once('...')
#15 16.03 #3 /srv/app/vendor/phpro/grumphp/bin/grumphp(51): ***closure***()
#15 16.03 #4 /srv/app/vendor/bin/grumphp(119): include('...')
#15 16.03 #5 ***main***
#15 16.03   thrown in /srv/app/vendor/composer/autoload_real.php on line 41
#15 16.04 GrumPHP can not sniff your commits! (invalid-exit-code)

because some Composer plugins want to do something on post-autoload-dump and they fail to do it because what I wrote earlier.

I can't add --no-plugins to Docker build command, because it does not work then:

$ composer patches-repatch --no-plugins
Plugins have been disabled, which may be why some commands are missing, unless you made a typo

  Command "patches-repatch" is not defined.

It's not critical, as our build continues even with the autoloader dump issues, but it would be better to not see these warnings/errors in the output and not execute something that simply can't work.

Describe your proposed solution(s)

Support --no-autoloader flag just like composer install/update do.

Describe alternatives

Config option (dump_autoloader)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew features, options, or other additions.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions