<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tiago Santos on Medium]]></title>
        <description><![CDATA[Stories by Tiago Santos on Medium]]></description>
        <link>https://medium.com/@tiagomssantos?source=rss-91136f77e09b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*M3q6cJFHzmWQyXtu8soi_w.jpeg</url>
            <title>Stories by Tiago Santos on Medium</title>
            <link>https://medium.com/@tiagomssantos?source=rss-91136f77e09b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 16:49:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tiagomssantos/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Deployer recipe for Drupal 8]]></title>
            <link>https://medium.com/@tiagomssantos/deployer-recipe-for-drupal-8-1d8c4acae6fd?source=rss-91136f77e09b------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d8c4acae6fd</guid>
            <category><![CDATA[deployer]]></category>
            <category><![CDATA[deploy]]></category>
            <category><![CDATA[drupal]]></category>
            <dc:creator><![CDATA[Tiago Santos]]></dc:creator>
            <pubDate>Fri, 10 Apr 2020 11:15:14 GMT</pubDate>
            <atom:updated>2020-04-10T11:15:14.235Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h1H6QRMd0uwRywSLM54NNg.jpeg" /><figcaption>Nice photo by <a href="https://unsplash.com/@toddquackenbush?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Todd Quackenbush</a> on <a href="https://unsplash.com/s/photos/cookbook?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a>. Nasty logo composition by me.</figcaption></figure><p>We all know that deployment is a PITA. Fortunately, we have tools like <a href="https://deployer.org/">Deployer</a> that make our lives easier. Deployer is an open-source tool to deploy PHP applications, it is composed of “recipe” scripts with tasks that support Drupal deployments, but also of other MVC/CMS like Laravel, CakePHP, Codeigniter or WordPress.</p><p>Deployer enables the following features:</p><ul><li>Parallel deployment. Roll out new features on different servers at the same time.</li><li>Agentless utility. Just set up SSH access to the remote machine and you are good to go.</li><li>Rollback. Screwed up? No problem, you can rollback applications to the previous version with a command.</li><li>Zero downtime. It creates a release for every new deployment so you can switch between different releases without downtime.</li></ul><p>I won’t dwell more on Deployer’s presentation, this <a href="https://www.alibabacloud.com/blog/automating-your-php-application-deployment-with-php-deployer_594654">article</a> provides a good explanation of its basic functioning. I suggest you read it and then, if you don’t get stuck on mindless internet surfing, like I often do, feel free to jump to the following lines.</p><h3>The basic recipe</h3><p>Deployer comes with recipes for <a href="https://github.com/deployphp/deployer/blob/master/recipe/drupal7.php">Drupal 7</a> and <a href="https://github.com/deployphp/deployer/blob/master/recipe/drupal8.php">8</a> and they pretty much work out of the box. You can have every definition in deploy.php recipe file, but I find useful to have the hosting definitions on hosts.yml.</p><p>Let&#39;s start there:</p><pre># hosts.yml<br><br>.base: &amp;base<br>  writable_mode: chmod<br>  port: 22<br>  shellCommand: bash -ls<br>  identityFile: ~/.ssh/yoursshhostnamekeys<br>  drush_path: /usr/local/bin/php -q ~/.composer/vendor/drush/drush/drush.php --php=/usr/local/bin/php # Useful if you want to perform drush tasks on remote server<br>  ssh_type: native<br>  multiplexing: false<br>  sshOptions:<br>    StrictHostKeyChecking: no<br><br>staging.yourhostname:<br>  &lt;&lt;: *base<br>  stage: staging<br>  hostname: your-hostname.com<br>  user: your-ssh-username<br>  deploy_path: /thefullpathtotheserver<br>  drush_alias: staging.yourhostname # I find useful to have the drush alias for the tasks that involve local drush support<br>  env_file: env/.env.staging # More into this later<br><br>production.yourhostname:<br>  &lt;&lt;: *base<br>  stage: production<br>  # ... You&#39;ve got the drill</pre><p>As you see, nothing complicated going on here. First we create a base where we define basic SSH configuration and then we define the different environments.</p><p>So let’s head on to the recipe:</p><pre># deploy.php<br><br>&lt;?php<br>namespace Deployer;<br><br>require &#39;recipe/common.php&#39;;<br>require &#39;recipe/drupal8.php&#39;;<br>require &#39;recipe/rsync.php&#39;;<br><br>// Hosts<br>inventory(&#39;hosts.yml&#39;); # Import our hosting definitions<br><br>// Project name<br>set(&#39;application&#39;, &#39;yourapplicationame&#39;);<br><br>// Keep 3 releases only<br>set(&#39;keep_releases&#39;, 3);<br><br>set(&#39;rsync_src&#39;, &#39;../../web&#39;);<br>set(&#39;rsync_dest&#39;,&#39;{{release_path}}/web&#39;);<br><br>//Set drupal site. Change if you use different site<br>set(&#39;drupal_site&#39;, &#39;default&#39;);<br><br>//Drupal 8 shared dirs<br>set(&#39;shared_dirs&#39;, [<br>    &#39;sites/{{drupal_site}}/files&#39;,<br>]);<br><br>//Drupal 8 shared files<br>set(&#39;shared_files&#39;, [<br>    &#39;sites/{{drupal_site}}/settings.local.php&#39;,<br>    &#39;sites/{{drupal_site}}/settings.php&#39;,<br>    &#39;sites/{{drupal_site}}/services.yml&#39;,<br>]);<br><br>//Drupal 8 Writable dirs<br>set(&#39;writable_dirs&#39;, [<br>    &#39;sites/{{drupal_site}}/files&#39;,<br>]);<br><br>set(&#39;rsync&#39;,[<br>    &#39;exclude&#39;       =&gt; [&#39;/sites/default/settings.local.php&#39;, &#39;/themes/your-theme/scss/*&#39;],<br>    &#39;exclude-file&#39;  =&gt; false,<br>    &#39;include&#39;       =&gt; [],<br>    &#39;include-file&#39;  =&gt; false,<br>    &#39;filter&#39;        =&gt; [],<br>    &#39;filter-file&#39;  =&gt; false,<br>    &#39;filter-perdir&#39; =&gt; false,<br>    &#39;flags&#39;         =&gt; &#39;rzcEPu&#39;, // Recursive, with compress, check based on checksum rather than time/size, preserve Executable flag<br>    &#39;options&#39;       =&gt; [], //Delete after successful transfer, delete even if deleted dir is not empty. Use &#39;dry-run&#39; to test.<br>    &#39;timeout&#39;       =&gt; 3600, //for those huge repos or crappy connection<br>]);<br><br>desc(&#39;Deploy your project&#39;);<br>task(&#39;deploy&#39;, [<br>    &#39;deploy:info&#39;,<br>    &#39;deploy:prepare&#39;,<br>    &#39;deploy:lock&#39;,<br>    &#39;deploy:release&#39;,<br>    &#39;rsync:warmup&#39;,<br>    &#39;rsync&#39;,<br>    &#39;deploy:shared&#39;,<br>    &#39;deploy:writable&#39;,<br>    &#39;deploy:symlink&#39;,<br>    &#39;deploy:unlock&#39;,<br>    &#39;cleanup&#39;<br>]);<br><br>// [Optional] If deploy fails automatically unlock.<br>after(&#39;deploy:failed&#39;, &#39;deploy:unlock&#39;);</pre><p>If you get an error stating that Deployer is unable to find the composer installed recipes, simply add to deploy.php:</p><pre>$composerHome = getenv(&quot;COMPOSER_HOME&quot;) ?: (getenv(&quot;HOME&quot;) . &#39;/.composer/&#39;);<br>if (is_dir($composerHome)) {<br>    include $composerHome . &#39;/vendor/autoload.php&#39;;<br>} else {<br>    $xdgComposerHome = getenv(&#39;XDG_CONFIG_HOME&#39;) ?: (getenv(&quot;HOME&quot;) . &#39;/.config&#39;);<br>    $xdgComposerHome = $xdgComposerHome . &#39;/composer&#39;;<br>    if (is_dir($xdgComposerHome)) {<br>        include $xdgComposerHome . &#39;/vendor/autoload.php&#39;;<br>    }<br>}</pre><p>Most of the recipe is based on the Drupal 8 recipe, the main difference is the introduction of the <a href="https://github.com/deployphp/recipes/blob/master/recipe/rsync.php">rsync recipe</a>, that replaces the functionality of the default update_code task. The latter task pulls a git repository from a defined git source and I want to avoid this, because I want to have more control over the uploaded files. This is especially important when the list of ignored files is different from the files we want to push to the server. Using the rsync recipe, you can define the source and destiny of the files to upload, and exclude/include the files you want within the rsync task.</p><p>This recipe should get you through simple Drupal deployments, but we can build upon it to add support to other tasks.</p><h4>Check the following posts in this series in my blog <strong>→</strong></h4><h3>References</h3><ul><li><a href="https://deployer.org/">Deployer</a></li><li><a href="https://www.alibabacloud.com/blog/automating-your-php-application-deployment-with-php-deployer_594654">Automating Your PHP Application Deployment with PHP Deployer</a></li><li><a href="https://github.com/deployphp/deployer/blob/master/recipe/drupal7.php">Drupal 7 rsync recipe</a></li><li><a href="https://github.com/deployphp/deployer/blob/master/recipe/drupal8.php">Drupal 8 rsync recipe</a></li><li><a href="https://github.com/deployphp/recipes/blob/master/recipe/rsync.php">Rsync recipe</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d8c4acae6fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>