From 8d0019ef3245109f70e187d0aa8479606fb3def9 Mon Sep 17 00:00:00 2001 From: M-arcus <25648755+M-arcus@users.noreply.github.com> Date: Thu, 8 Jan 2026 16:58:12 +0100 Subject: [PATCH 1/2] Update readme with more information regarding v2 --- README.md | 68 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index cd8b428a..835d2a0c 100644 --- a/README.md +++ b/README.md @@ -13,14 +13,10 @@ composer require symplify/vendor-patches --dev composer require cweagans/composer-patches ``` -
- ## Usage How to create [a patch for a file in `/vendor`](https://tomasvotruba.com/blog/2020/07/02/how-to-patch-package-in-vendor-yet-allow-its-updates/)? -
- ### 1. Create a Copy of `/vendor` file you Want To Change with `*.old` Suffix For example, if you edit: @@ -31,8 +27,6 @@ vendor/nette/di/src/DI/Extensions/InjectExtension.php vendor/nette/di/src/DI/Extensions/InjectExtension.php.old ``` -
- ### 2. Open the original file and change the lines you need: ```diff @@ -45,7 +39,7 @@ vendor/nette/di/src/DI/Extensions/InjectExtension.php.old Only `*.php` file is loaded, not the `*.php.old` one. This way you can **be sure the new code** is working before you generate patches. -
+Make sure to back up other modified files in the vendor/ directory as well as some of the commands below may overwrite them. ### 3. Run `generate` command 🥳️ @@ -61,8 +55,6 @@ This tool will generate **patch files for all files created this** way in `/patc The patch path is based on original file path, so **the patch name is always unique**. -
- Also, it will add configuration for `cweagans/composer-patches` to your `composer.json`: ```json @@ -77,23 +69,31 @@ Also, it will add configuration for `cweagans/composer-patches` to your `compose } ``` -
+#### 3.1 When using cweagans/composer-patches v2 -Optionally, if you use a [patches file](https://docs.cweagans.net/composer-patches/usage/defining-patches/#patches-file) you can specify its path using the `--patches-file` option: +`cweagans/composer-patches` v2 requires the execution of 2 additional steps after generating the patches: + +Updating the `patches.lock.json` file: ```bash -vendor/bin/vendor-patches generate --patches-file=patches.json +composer patches-relock ``` -You can choose to write the patches to a different folder than the default 'patches' folder by specifying the folder name using the `--patches-folder` option: +Applying the new patches: ```bash -vendor/bin/vendor-patches generate --patches-folder=patches-composer +composer patches-repatch ``` -That's it! +### 4. Final steps + +Now you need to do run composer to update the lock file as the checksum of `composer.json` has changed: + +```bash +composer update --lock +``` -
+That's it! Now all you need to do is run composer: @@ -103,15 +103,41 @@ composer install And your patches are applied to your code! -
- If not, get more information from composer to find out why: ```bash composer install --verbose ``` -
+### Summary + +To summarize, the generate workflow is: + +```bash +# generate patches +vendor/bin/vendor-patches generate +# (if using cweagans/composer-patches v2) +composer patches-relock +composer patches-repatch +# update the lock file +composer update --lock +# install with patches applied +composer install +``` + +## Patches File and Patches Folder Options + +Optionally, if you use a [patches file](https://docs.cweagans.net/composer-patches/usage/defining-patches/#patches-file) you can specify its path using the `--patches-file` option: + +```bash +vendor/bin/vendor-patches generate --patches-file=patches.json +``` + +You can choose to write the patches to a different folder than the default 'patches' folder by specifying the folder name using the `--patches-folder` option: + +```bash +vendor/bin/vendor-patches generate --patches-folder=patches-composer +``` ## TroubleShooting @@ -121,7 +147,7 @@ If you are upgrading `cweagans/composer-patches` to 2.0.0 and newer versions, yo The new version requires that `--- /dev/null` needs to be replaced with `--- ` in your patch files. -For example, if you have a old patch file that starts with: +For example, if you have an old patch file that starts with: ```diff --- /dev/null @@ -153,5 +179,3 @@ and register to `.bash_profile` or `.zshrc` (if you're using [oh-my-zsh](https:/ ``` PATH="/opt/homebrew/opt/gpatch/libexec/gnubin:$PATH" ``` - -
From f2fe48a96d8aa9930e02298c749e6b36f52b09b1 Mon Sep 17 00:00:00 2001 From: M-arcus <25648755+M-arcus@users.noreply.github.com> Date: Thu, 8 Jan 2026 19:01:18 +0100 Subject: [PATCH 2/2] Keep br tags --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 835d2a0c..355e5445 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,14 @@ composer require symplify/vendor-patches --dev composer require cweagans/composer-patches ``` +
+ ## Usage How to create [a patch for a file in `/vendor`](https://tomasvotruba.com/blog/2020/07/02/how-to-patch-package-in-vendor-yet-allow-its-updates/)? +
+ ### 1. Create a Copy of `/vendor` file you Want To Change with `*.old` Suffix For example, if you edit: @@ -27,6 +31,8 @@ vendor/nette/di/src/DI/Extensions/InjectExtension.php vendor/nette/di/src/DI/Extensions/InjectExtension.php.old ``` +
+ ### 2. Open the original file and change the lines you need: ```diff @@ -41,6 +47,8 @@ Only `*.php` file is loaded, not the `*.php.old` one. This way you can **be sure Make sure to back up other modified files in the vendor/ directory as well as some of the commands below may overwrite them. +
+ ### 3. Run `generate` command 🥳️ ```bash @@ -55,6 +63,8 @@ This tool will generate **patch files for all files created this** way in `/patc The patch path is based on original file path, so **the patch name is always unique**. +
+ Also, it will add configuration for `cweagans/composer-patches` to your `composer.json`: ```json @@ -69,6 +79,8 @@ Also, it will add configuration for `cweagans/composer-patches` to your `compose } ``` +
+ #### 3.1 When using cweagans/composer-patches v2 `cweagans/composer-patches` v2 requires the execution of 2 additional steps after generating the patches: @@ -95,6 +107,8 @@ composer update --lock That's it! +
+ Now all you need to do is run composer: ```bash @@ -103,6 +117,8 @@ composer install And your patches are applied to your code! +
+ If not, get more information from composer to find out why: ```bash @@ -139,6 +155,8 @@ You can choose to write the patches to a different folder than the default 'patc vendor/bin/vendor-patches generate --patches-folder=patches-composer ``` +
+ ## TroubleShooting ### Upgrading from older versions of cweagans/composer-patches (pre 2.0.0) @@ -179,3 +197,5 @@ and register to `.bash_profile` or `.zshrc` (if you're using [oh-my-zsh](https:/ ``` PATH="/opt/homebrew/opt/gpatch/libexec/gnubin:$PATH" ``` + +