{"id":52,"date":"2019-04-02T16:53:59","date_gmt":"2019-04-02T16:53:59","guid":{"rendered":"https:\/\/serioussemicolons.wordpress.com\/?p=52"},"modified":"2019-04-02T16:53:59","modified_gmt":"2019-04-02T16:53:59","slug":"quick-tip-testing-feature-branches-with-composer","status":"publish","type":"post","link":"https:\/\/blog.bryant.ai\/?p=52","title":{"rendered":"Quick Tip: Testing Feature Branches with Composer"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I was adding a new feature to my <a href=\"https:\/\/packagist.org\/packages\/syntaxera\/cakephp-secureids-plugin\">CakePHP SecureIDs Plugin<\/a> today and needed to test it against a living, breathing CakePHP app. Rather than spin up a brand-new one, I decided to use an existing app I had on hand for a contract I have open. Thing was, I didn&#8217;t want to go through the whole rigamarole of creating a release, pushing it, waiting for it to hit Packagist, waiting for Composer to see it, and only <em>then<\/em> being able to add it as a dependency to my app.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Composer is a smart tool, and so is <a href=\"https:\/\/www.atlassian.com\/git\/tutorials\/comparing-workflows\/gitflow-workflow\">git-flow<\/a>. Surely I can combine the two to bypass the above lengthy process and get testing faster, I thought. Turns out it&#8217;s totally possible, here&#8217;s how I did it in a few easy steps (I&#8217;ll go into greater detail in a minute):<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Start a feature branch in the plugin repo<\/li><li>Push the feature branch to the remote<\/li><li>In the test app&#8217;s <code>composer.json<\/code> add the repository the plugin sits in<\/li><li>Add the dependency with the version string <code>dev-feature\/feature-name<\/code><\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">For what it&#8217;s worth, I didn&#8217;t think this was gonna work because I was sure Composer was gonna choke on the <code>\/<\/code> in the branch name&#8230;but nope! Handled it just fine. \ud83d\udc4c<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Breakdown<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">So what does all this mean? In short, the steps above describe a way to short-circuit the package release process used in testing dependencies with <a href=\"https:\/\/getcomposer.org\/\">Composer<\/a>. Normally it&#8217;s a lengthy process with lots of steps in between committing your code and actually seeing it work in a living-breathing app, but the process I described above is a better way <strong>if you&#8217;re just testing things or making temporary changes.<\/strong> Don&#8217;t use this process to release code into the wild, it&#8217;s not a good idea.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In order to use the steps above, your repo must be <a href=\"https:\/\/www.atlassian.com\/git\/tutorials\/comparing-workflows\/gitflow-workflow\">git-flow<\/a> enabled. Git flow is a very powerful tool that I&#8217;ve used for years to keep my development process sane and well-organized, especially when working in teams. I don&#8217;t have time to evangelize GF properly here, so I&#8217;ll leave that up to some other qualified individuals:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/datasift.github.io\/gitflow\/IntroducingGitFlow.html\">What is Git Flow?<\/a> on datasift&#8217;s Github page<\/li><li><a href=\"https:\/\/www.atlassian.com\/git\/tutorials\/comparing-workflows\/gitflow-workflow\">Gitflow Workflow<\/a> on the excellent Atlassian Git tutorials site<\/li><li><a href=\"https:\/\/bjurr.com\/gitflow-and-when-you-should-use-it\/\">GitFlow and when you should use it<\/a> on Tomas Bjerre&#8217;s blog<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Composer is a smart tool, and so is git-flow\ufeff. Surely I can combine the two to bypass the above lengthy process and get testing faster, I thought. Turns out it&#8217;s totally possible, here&#8217;s how I did it in a few easy steps.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[12,18,23,34],"class_list":["post-52","post","type-post","status-publish","format-standard","hentry","category-development","tag-cakephp","tag-composer","tag-git-flow","tag-plugin"],"_links":{"self":[{"href":"https:\/\/blog.bryant.ai\/index.php?rest_route=\/wp\/v2\/posts\/52","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bryant.ai\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bryant.ai\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bryant.ai\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bryant.ai\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=52"}],"version-history":[{"count":0,"href":"https:\/\/blog.bryant.ai\/index.php?rest_route=\/wp\/v2\/posts\/52\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.bryant.ai\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bryant.ai\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bryant.ai\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}