Apply drupal path using composer
What is a drupal patch?
Patch is the file created by someone (drupal community) to modify the core, module or theme. The reason to apply the patch is to fix the bug to (the module for example that the author not yet done, because of some reason), but someone do. That patch file was tested and secure to apply.
The patch will make a change without directly hacking the files. (Directly changing files is always a bad solution because all our changes will be deleted with the next update!)
How to apply patch
In this example, we want to apply the patch to the Pathauto module, as recomanded in this this link. Below is the screenshot for the patch. See how we implement this patch as step 3 below: "Issue #3275041": "https://www.drupal.org/files/issues/2022-04-13/add_bypass_uniquifier_se…"
Note: The description Issue #3275041 above can be anything you want. In this example, we used Issue #3275041, but you can also use the title or URL of the issue.

- Open the terminal and position the location to the specific module that we want to apply patch
- Run: composer require cweagans/composer-patches
- Add the appropriate configuration to the extra section of the main composer.json file of your project
- Go to web/modules/contrib/pathauto/composer.json
- Look at "extra" & paste the patch code as below & save
"extra": {
"patches": {
"drupal/pathauto": {
"Issue #3275041": "https://www.drupal.org/files/issues/2022-04-13/add_bypass_uniquifier_se…"
}
},
"enable-patching": true
}
- Run: composer install
Do the patch to unlock version
Usually, a patch is created only for a specific version of a module. This means the same patch will likely not work for a new version, that obviously can lead to outdated modules.
Unlock version look like this: "drupal/webform": "^6.0"
Lock version look like this: "drupal/webform": "6.1.4"
So, better to do the patch with unlock version
- How to apply a patch in Drupal
- Learn How To Apply A Patch to a Drupal Module (YouTube)
- How to install modules that are not Drupal 10 compatible?
- https://gorannikolovski.com/blog/how-to-apply-a-patch-in-drupal
- https://wpwebinfotech.com/blog/how-to-apply-patch-in-drupal/
client = ca-pub-2898279488603899
slot = 9058461004
format = auto