See also this alternative approach: https://gist.github.com/cmtickle/8900629447429126ffd7ff84e56ec780#to-patch-code-in-appcode
If you need to patch an M2 extension that isn't available to be installed via Composer, and you're concerned about losing edits directly to files in app/code/<Vendor>
directory, you can install and then patch the extension locally using these steps:
-
Copy the extension into an arbitrary folder location like
app/code/packages/VendorName/ModuleName
(this assumes this module has acomposer.json
file with the package name ofvendorname/module-modulename
) -
Run this command to add your custom package location to the composer repositories list:
composer config repositories.vendorname/module-modulename path app/packages/VendorName/ModuleName
-
Require the extension: