jobiqo / composer-patches-install
Composer plugin that detects patches.lock.json changes and triggers re-patching of affected packages.
Package info
github.com/jobiqo/composer-patches-install
Type:composer-plugin
pkg:composer/jobiqo/composer-patches-install
Requires
- php: ^8.1
- composer-plugin-api: ^2.0
- cweagans/composer-patches: ^2.0
Requires (Dev)
- composer/composer: ^2.0
README
A Composer plugin that detects patches.lock.json changes and automatically triggers re-patching of affected packages. See cweagans/composer-patches#583
This is relevant for sites that use a git pull && composer install workflow. With composer-patches 2.x this is not sufficient anymore to get any patches.lock.json changes installed. The workaround is git pull && composer install && composer patches-repatch, but has downsides:
- Local development: developers need to remember a much longer command when they update their checkout,
composer installis not enough anymore. - Longer production downtimes than necessary. A full
composer patches-repatchtriggers all patched dependencies to be patched again, which is slow.
What it does internally
- On a fresh install (no
vendor/directory), pre-initialises thepatches.lock.jsoncache so the firstcomposer installdoes not trigger unnecessary reinstalls. - On subsequent composer install, compares
patches.lock.jsonagainst the cached copy invendor/composer/patches.lock.json. - Re-installs only the packages whose patch hashes have changed, so patches are always applied consistently.
- Supports
--no-devmode: dev-only packages are skipped when running without dev dependencies.
Requirements
- PHP 8.1+
- Composer 2.x
cweagans/composer-patches^2.0
Installation
composer require jobiqo/composer-patches-install
Usage
Generate a patches.lock.json file with composer-patches in the root of your project (next to composer.json). The plugin reads the patches key and its sha256 hashes (as written by cweagans/composer-patches v2) to decide which packages need to be reinstalled.
Run composer install and patch changes will be picked up automatically.