{"id":27280,"date":"2017-01-31T13:17:05","date_gmt":"2017-01-31T11:17:05","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/?p=27280"},"modified":"2017-01-31T13:17:05","modified_gmt":"2017-01-31T11:17:05","slug":"composer-patches-simple-patches-plugin-for-composer","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2017\/01\/31\/composer-patches-simple-patches-plugin-for-composer\/","title":{"rendered":"composer-patches &#8211; Simple patches plugin for Composer"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p><a href=\"https:\/\/github.com\/cweagans\/composer-patches\">composer-patches<\/a> is a plugin for Composer which helps with applying patches to the installed dependencies. \u00a0It supports patches from URLs, local files, and from other dependencies.<\/p>\n<p>I think this is absolutely brilliant!<\/p>\n<p>It&#8217;s quite often that one finds bugs and issues in external dependencies. \u00a0Once the bug (or even the pull request with the fix) is submitted to the vendor, it can take anywhere from a few hours to a few weeks to be resolved and a new version to be released.<\/p>\n<p>If you have a fix for the problem and need it in your project right away, and can&#8217;t wait until the vendor releases the new version, your best choice is to fork the dependency, fix the problem, and use your repository instead of the vendor&#8217;s package. \u00a0This works, but it&#8217;s messy.<\/p>\n<p>With the patches plugin to composer, you can still use the vendor&#8217;s package and just apply a patch with composer, until the new version is available. \u00a0Clean and simple.<\/p>\n<p>This also helps with testing things and working with different changes by different people, if you want to try things out &#8211; no need to choose between multiple repositories. \u00a0Just select the patches that you want and apply them at the environment you need.<\/p>\n<p>Given that most development work is happening on GitHub these days, this composer plugin is even more useful than what I might think at first. \u00a0You see, GitHub provides patch and diff URL for each commit &#8211; all you need to do is add the extension to the URL. \u00a0For example, take <a href=\"https:\/\/github.com\/mamchenkov\/dotfiles\/commit\/e3d1791ea5c416252c42761a06ba58451932631f\">this recent commit<\/a> to my dotfiles repository.<\/p>\n<figure id=\"attachment_27281\" aria-describedby=\"caption-attachment-27281\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/commit.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"27281\" data-permalink=\"https:\/\/mamchenkov.net\/wordpress\/2017\/01\/31\/composer-patches-simple-patches-plugin-for-composer\/commit\/\" data-orig-file=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/commit.png?fit=999%2C525&amp;ssl=1\" data-orig-size=\"999,525\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"commit\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/commit.png?fit=660%2C347&amp;ssl=1\" class=\"wp-image-27281 size-medium\" src=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/commit-500x263.png?resize=500%2C263&#038;ssl=1\" width=\"500\" height=\"263\" srcset=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/commit.png?resize=500%2C263&amp;ssl=1 500w, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/commit.png?resize=768%2C404&amp;ssl=1 768w, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/commit.png?w=999&amp;ssl=1 999w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-27281\" class=\"wp-caption-text\">Commit screen<\/figcaption><\/figure>\n<p>If you add a &#8220;<em>.patch<\/em>&#8221; extension to this URL, you&#8217;ll get a <a href=\"https:\/\/github.com\/mamchenkov\/dotfiles\/commit\/e3d1791ea5c416252c42761a06ba58451932631f.patch\">patch output<\/a>, which is useful for <em>git am<\/em>, and other commands (<a href=\"http:\/\/alblue.bandlem.com\/2011\/12\/git-tip-of-week-patches-by-email.html\">more on using git with email<\/a>):<\/p>\n<figure id=\"attachment_27282\" aria-describedby=\"caption-attachment-27282\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/patch.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"27282\" data-permalink=\"https:\/\/mamchenkov.net\/wordpress\/2017\/01\/31\/composer-patches-simple-patches-plugin-for-composer\/patch\/\" data-orig-file=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/patch.png?fit=622%2C334&amp;ssl=1\" data-orig-size=\"622,334\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"patch\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/patch.png?fit=622%2C334&amp;ssl=1\" class=\"wp-image-27282 size-medium\" src=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/patch-500x268.png?resize=500%2C268&#038;ssl=1\" width=\"500\" height=\"268\" srcset=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/patch.png?resize=500%2C268&amp;ssl=1 500w, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/patch.png?w=622&amp;ssl=1 622w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-27282\" class=\"wp-caption-text\">Patch screen<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p>If you add a &#8220;<em>.diff<\/em>&#8221; extension to this URL, you&#8217;ll get a <a href=\"https:\/\/github.com\/mamchenkov\/dotfiles\/commit\/e3d1791ea5c416252c42761a06ba58451932631f.diff\">unified diff output<\/a>, which you can either apply with <em>diff<\/em> and <em>patch<\/em> utils, or use with the <a href=\"https:\/\/github.com\/cweagans\/composer-patches\">composer-patches plugin<\/a>.<\/p>\n<figure id=\"attachment_27283\" aria-describedby=\"caption-attachment-27283\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/diff.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"27283\" data-permalink=\"https:\/\/mamchenkov.net\/wordpress\/2017\/01\/31\/composer-patches-simple-patches-plugin-for-composer\/diff\/\" data-orig-file=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/diff.png?fit=655%2C207&amp;ssl=1\" data-orig-size=\"655,207\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"diff\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/diff.png?fit=655%2C207&amp;ssl=1\" class=\"wp-image-27283 size-medium\" src=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/diff-500x158.png?resize=500%2C158&#038;ssl=1\" width=\"500\" height=\"158\" srcset=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/diff.png?resize=500%2C158&amp;ssl=1 500w, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/diff.png?w=655&amp;ssl=1 655w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-27283\" class=\"wp-caption-text\">Unified diff screen<\/figcaption><\/figure>\n<p>So, this gives you a way of applying any commit on GitHub (and other repositories) via composer to any of your dependencies. \u00a0This is mind blowing!<\/p>\n<p>&nbsp;<\/p>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>composer-patches is a plugin for Composer which helps with applying patches to the installed dependencies. \u00a0It supports patches from URLs, local files, and from other dependencies. I think this is absolutely brilliant! It&#8217;s quite often that one finds bugs and issues in external dependencies. \u00a0Once the bug (or even the pull request with the fix) &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2017\/01\/31\/composer-patches-simple-patches-plugin-for-composer\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">composer-patches &#8211; Simple patches plugin for Composer<\/span><\/a><\/p>\n<!-- google_ad_section_end -->\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"composer-patches - Simple patches plugin for Composer #WebDev #PHP #composer #git #GitHub","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_links_to":"","_links_to_target":""},"categories":[1,18,62,1334],"tags":[3489,2265,2809,38,1588,1330],"keyring_services":[],"class_list":["post-27280","post","type-post","status-publish","format-standard","hentry","category-general","category-programming","category-technology","category-web-work","tag-composer","tag-git","tag-github","tag-php","tag-version-control","tag-web-development"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":27363,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/02\/26\/composer-require-inline-alias\/","url_meta":{"origin":27280,"position":0},"title":"Composer require inline alias","author":"Leonid Mamchenkov","date":"February 26, 2017","format":false,"excerpt":"Here's a feature of composer that I didn't know about until a few days ago - require inline alias. \u00a0Here's the example from the documentation: This is super useful when you have dependencies in your project that require a particular version of a third-party library or plugin, and you want\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":28559,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/05\/08\/composer-plugin-qa-composer-plugin-for-php-quality-assurance-tools\/","url_meta":{"origin":27280,"position":1},"title":"composer-plugin-qa &#8211; Composer Plugin for PHP Quality Assurance Tools","author":"Leonid Mamchenkov","date":"May 8, 2018","format":false,"excerpt":"composer-plugin-qa is a Composer plugin which adds all the most popular PHP quality assurance tools as composer scripts, so that you don't have to install and set them up one by one.\u00a0 The list of tools includes the following: PHPUnit: Testing Framework PHPCOV: CLI frontend for the\u00a0PHP_CodeCoverage Paratest: Parallel testing\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2018\/05\/composer-plugin-qa-500x296.jpeg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":26051,"url":"https:\/\/mamchenkov.net\/wordpress\/2016\/04\/21\/adventure-in-composer-private-repositories\/","url_meta":{"origin":27280,"position":2},"title":"Adventure in composer private repositories","author":"Leonid Mamchenkov","date":"April 21, 2016","format":false,"excerpt":"First of all, I would like to take this opportunity and wish composer a happy birthday and many more years to come. \u00a0It's been five years, and the world of PHP has changed so drastically that not many people remember how it used to be before. I would have completely\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":44293,"url":"https:\/\/mamchenkov.net\/wordpress\/2019\/09\/23\/github-adds-php-and-composer-dependency-graphs\/","url_meta":{"origin":27280,"position":3},"title":"GitHub adds PHP and Composer dependency graphs","author":"Leonid Mamchenkov","date":"September 23, 2019","format":false,"excerpt":"Here are some great news from GitHub: Dependency graph support is now available for PHP repositories with Composer dependencies. You may see security alerts on your repositories as dependency graph support rolls out. When there\u2019s a published vulnerability on any of the Composer dependencies that your project lists in\u00a0composer.json\u00a0and\u00a0composer.lock\u00a0files, GitHub\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/09\/github-php-composer.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/09\/github-php-composer.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/09\/github-php-composer.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/09\/github-php-composer.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/09\/github-php-composer.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/09\/github-php-composer.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":28431,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/03\/14\/updating-wordpress-with-composer-and-wp-cli\/","url_meta":{"origin":27280,"position":4},"title":"Updating WordPress with Composer and WP-CLI","author":"Leonid Mamchenkov","date":"March 14, 2018","format":false,"excerpt":"The other day I came across this blog post by\u00a0Mark Jaquith, who is one of the lead contributors to WordPress, in which he describes his process of updating WordPress plugins with WP-CLI and Git.\u00a0 I think a lot of people these days are trying to use Git for version control\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":30254,"url":"https:\/\/mamchenkov.net\/wordpress\/2019\/01\/29\/php-composer-galaxy\/","url_meta":{"origin":27280,"position":5},"title":"PHP : Composer Galaxy","author":"Leonid Mamchenkov","date":"January 29, 2019","format":false,"excerpt":"PHP has one of the greatest, in my opinion, dependency managers - Composer. The tool works mostly with the public projects via the Packagist website (although it also supports private repositories). There are over 200,000 packages available on the Packagist to choose from. However, the stats could be a lot\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/01\/composer.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/01\/composer.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/01\/composer.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/01\/composer.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/01\/composer.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/01\/composer.png?resize=1400%2C800&ssl=1 4x"},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/27280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/comments?post=27280"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/27280\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=27280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=27280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=27280"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=27280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}