{"id":28325,"date":"2018-01-10T12:13:39","date_gmt":"2018-01-10T10:13:39","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/?p=28325"},"modified":"2018-01-10T12:13:39","modified_gmt":"2018-01-10T10:13:39","slug":"17-tips-for-using-composer-efficiently","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2018\/01\/10\/17-tips-for-using-composer-efficiently\/","title":{"rendered":"17 Tips for Using Composer Efficiently"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p><a href=\"https:\/\/blog.martinhujer.cz\/\">Martin Hujer<\/a> has collected <a href=\"https:\/\/blog.martinhujer.cz\/17-tips-for-using-composer-efficiently\/\">17 tips for using composer efficiently<\/a>, and then added a few more after receiving the feedback on the blog post.\u00a0 I was familiar with most of these, but there are still a few that are new to me.<\/p>\n<blockquote><p>Tip #7: Run Travis CI builds with different versions of dependencies<\/p><\/blockquote>\n<p>I knew about the Travis CI matrix configuration, but used it only for other things.\u00a0 I&#8217;ll be looking into extending it for the composer tests shortly.<\/p>\n<blockquote><p>Tip #8: Sort packages in require and require-dev by name<\/p><\/blockquote>\n<p>This is a great tip!\u00a0 I read the composer documentation several times, but somehow I missed this option.\u00a0 It is especially useful for the the way we manage projects at work (waterfall merges from templates and basic projects into more complex ones).<\/p>\n<blockquote><p>Tip #9: Do not attempt to merge composer.lock when rebasing or merging<\/p><\/blockquote>\n<p>Here, I&#8217;m not quite sure about the whole bit on git attributes.\u00a0 Having git try to merge and generate a conflict creates a very visible problem.\u00a0 Avoiding the merge might hide things a bit until they popup much later in the CI.\u00a0 I guess I&#8217;ll have to play around with this to make up my mind.<\/p>\n<blockquote><p>Tip #13: Validate the composer.json during the CI build<\/p><\/blockquote>\n<p>This is a great tip!\u00a0 I had plenty of issues with composer validations in the past.\u00a0 Currently, we have a couple of unit tests that make sure that composer files are valid and up-to-date.\u00a0 Using a native mechanism for that is a much better option.<\/p>\n<blockquote><p>Tip #15: Specify the production PHP version in composer.json<\/p><\/blockquote>\n<p>This sounds like an amazing feature which I once again missed.\u00a0 Especially now that we are still migrating some projects from PHP 5.6 to PHP 7.1, and have to sort out dependency conflicts between the two versions.<\/p>\n<blockquote><p>Tip #20: Use authoritative class map in production<\/p><\/blockquote>\n<p>We are already almost doing it, but it&#8217;s a good opportunity to verify that we utilize the functionality correctly.<\/p>\n<p>&nbsp;<\/p>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>Martin Hujer has collected 17 tips for using composer efficiently, and then added a few more after receiving the feedback on the blog post.\u00a0 I was familiar with most of these, but there are still a few that are new to me. Tip #7: Run Travis CI builds with different versions of dependencies I knew &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2018\/01\/10\/17-tips-for-using-composer-efficiently\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">17 Tips for Using Composer Efficiently<\/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":"17 Tips for Using Composer Efficiently #WebDev #PHP #composer #BestPractices","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":[3069,3489,38,1330],"keyring_services":[],"class_list":["post-28325","post","type-post","status-publish","format-standard","hentry","category-general","category-programming","category-technology","category-web-work","tag-best-practices","tag-composer","tag-php","tag-web-development"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":28916,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/11\/07\/show-outdated-composer-packages\/","url_meta":{"origin":28325,"position":0},"title":"Show outdated composer packages","author":"Leonid Mamchenkov","date":"November 7, 2018","format":false,"excerpt":"A while back I shared a way to show outdated composer packages.\u00a0 Today, I want to expand on it a little bit.\u00a0 Thanks to this tweet: https:\/\/twitter.com\/waltertamboer\/status\/1059567319725301762 I think it's slightly easy to remember with \"composer show -molD -strict\" (\"old\", \"mold\").\u00a0 Adding this to the test suite is a great\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":27363,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/02\/26\/composer-require-inline-alias\/","url_meta":{"origin":28325,"position":1},"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":26051,"url":"https:\/\/mamchenkov.net\/wordpress\/2016\/04\/21\/adventure-in-composer-private-repositories\/","url_meta":{"origin":28325,"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":30254,"url":"https:\/\/mamchenkov.net\/wordpress\/2019\/01\/29\/php-composer-galaxy\/","url_meta":{"origin":28325,"position":3},"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":[]},{"id":27460,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/03\/26\/composer-git-hooks-manage-git-hooks-in-your-composer-config\/","url_meta":{"origin":28325,"position":4},"title":"composer-git-hooks &#8211; manage git hooks in your composer config","author":"Leonid Mamchenkov","date":"March 26, 2017","format":false,"excerpt":"composer-git-hooks looks awesome! \u00a0From the project page description: Manage git hooks easily in your composer configuration. This package makes it easy to implement a consistent project-wide usage of git hooks. Specifying hooks in the composer file makes them available for every member of the project team. This provides a consistent\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":28394,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/02\/19\/composer-local-packages-for-dummies\/","url_meta":{"origin":28325,"position":5},"title":"Composer Local Packages for Dummies","author":"Leonid Mamchenkov","date":"February 19, 2018","format":false,"excerpt":"Composer (in combination with Packagist) is one technology that has significantly changed the ecosystem of the PHP programming language.\u00a0 Anybody working with PHP in this day and age MUST know how to use composer.\u00a0 However, not everyone does.\u00a0 So here is a nice tutorial on how to get started with\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\/02\/composer.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/28325","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=28325"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/28325\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=28325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=28325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=28325"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=28325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}