<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jae James</title>
    <description>The latest articles on DEV Community by Jae James (@jaejamesdev).</description>
    <link>https://dev.to/jaejamesdev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F165533%2Fce96d91a-c26c-4eaf-8adf-10bb6c115a43.jpeg</url>
      <title>DEV Community: Jae James</title>
      <link>https://dev.to/jaejamesdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jaejamesdev"/>
    <language>en</language>
    <item>
      <title>Lets Use Bitbucket Pipelines With Laravel/PHP</title>
      <dc:creator>Jae James</dc:creator>
      <pubDate>Sat, 11 May 2019 20:47:21 +0000</pubDate>
      <link>https://dev.to/jaejamesdev/lets-use-bitbucket-pipelines-with-laravel-php-428k</link>
      <guid>https://dev.to/jaejamesdev/lets-use-bitbucket-pipelines-with-laravel-php-428k</guid>
      <description>&lt;h2&gt;Hello, World!&lt;/h2&gt;

&lt;p&gt;I am a long time lover of Bitbucket (sorry GitHub fans) and Bitbucket Pipelines is by far one of my favorite CI/CD tools.&lt;br&gt;
Bitbucket Pipelines allows you to automatically build, test and even deploy your code, based on a configuration file in your repository. Oh and I almost forgot to mention, it's based on Docker for all you Docker fans out there ;)&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
So, Jae, what do I need to do to get started?&lt;br&gt;
&lt;br&gt;
Well... That is a very good question! It's actually really simple to setup even if you don't have an in-depth knowledge of how Docker works or what it is (although I do recommend you have a read up on Docker since it is pretty cool). All you need is a Bitbucket account and Bitbucket will give you 50 minutes of free build time  a month which should be more than enough for personal projects and side hustles.&lt;/p&gt;

&lt;p&gt;Now you have made a Bitbucket account and totally opted-in to Atlassian's marketing, let's get started with the fun stuff!&lt;/p&gt;

&lt;h3&gt;bitbucket-pipelines.yml&lt;/h3&gt;

&lt;p&gt;The beating heart for our CI/CD automated joy is our &lt;i&gt;bitbucket-pipelines.yml&lt;/i&gt; file. Now, you can generate this in one of two ways; The first way is by manually creating the file (this is what we will do in order for me to break each stage down), the second is by using the online generator which you can do by opening up your repository, clicking Pipelines on the left and it will take you through the visual wizard there to setting up your &lt;i&gt;bitbucket-pipelines.yml&lt;/i&gt; file.&lt;/p&gt;

&lt;p&gt;So... enough babbling on. Create a file in the route of your project called, you guessed it, &lt;i&gt;bitbucket-pipelines.yml&lt;/i&gt;. We'll populate the file with the following for now and I'll break it down.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;php:7.3&lt;/span&gt;

&lt;span class="na"&gt;pipelines&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;default&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;step&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;caches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;composer&lt;/span&gt;
        &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;apt-get update &amp;amp;&amp;amp; apt-get install -y unzip&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;composer install&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;cp .env.example .env&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;php artisan key:generate&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;vendor/bin/phpunit&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "Done!"&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let's look at the first line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;php7.3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This is the base Docker image that we want Bitbucket Pipelines to use. We can realistically change this to anything we want as long as the image is publicly available on DockerHub. For me however, I've found that the default PHP Docker image works just fine and contains everything I need dependency wise. If you want to use any other PHP version, just change the &lt;i&gt;7.3&lt;/i&gt; at the end, it really is as simple as that!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;pipelines&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;default&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;step&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;caches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;composer&lt;/span&gt;
        &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;apt-get update &amp;amp;&amp;amp; apt-get install -y unzip&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;composer install&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;cp .env.example .env&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;php artisan key:generate&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;vendor/bin/phpunit&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "Done!"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The above is the brains of our pipeline. As you can see, under pipelines we can define different pipelines to go down. This one is the default pipeline. This pipeline will be ran by default, automatically as long as the branch is setup to use pipelines (this is master by default). This is useful if you want automatic code testing.&lt;br&gt;
&lt;i&gt;caches:&lt;/i&gt; created a composer cache which means we don't need to run composer install if the composer.json file hasn't had an update since the last build.&lt;br&gt;
Under the script section, this should look oh so familiar. These are just typical Linux commands. We need to install Unzip since the PHP docker image is pretty barebones. Once doing so, we want to install composer and move it into the &lt;i&gt;/usr/local/bin&lt;/i&gt; directory so we can access it globally. From then on, we want to copy our &lt;i&gt;.env.example&lt;/i&gt; file to be our &lt;i&gt;.env&lt;/i&gt; file and generate an application key specifically for Bitbucket Pipelines. Then we just run PHPUnit to run our tests. This means if one of our tests fails, the build will fail and if you have email notifications configured, you'll get a lovely email in your inbox.&lt;/p&gt;

&lt;h2&gt;The Conclusion&lt;/h2&gt;

&lt;p&gt;It really is that simple... This will automatically build and test our code. Now we can go one step further in this by adding Deployment steps which will allow us to have access to buttons to deploy our code to various environments. Make sure to follow me as I'll be writing a post on how to deploy to Forge from Bitbucket Pipelines as a continuation to this little guide!&lt;/p&gt;

&lt;p&gt;&lt;b&gt;If anyone has any problems at all, leave a comment and I'll be sure to help out!&lt;/b&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>laravel</category>
      <category>devops</category>
      <category>bitbucket</category>
    </item>
    <item>
      <title>Bitbucket Pipelines &amp; The SoapClient</title>
      <dc:creator>Jae James</dc:creator>
      <pubDate>Sat, 11 May 2019 19:32:06 +0000</pubDate>
      <link>https://dev.to/jaejamesdev/bitbucket-pipelines-the-soapclient-47km</link>
      <guid>https://dev.to/jaejamesdev/bitbucket-pipelines-the-soapclient-47km</guid>
      <description>&lt;h2&gt;Hello, World!&lt;/h2&gt;

&lt;p&gt;This is my first post on the Dev community and it's just a quick little trick that I feel may help others!&lt;/p&gt;

&lt;p&gt;I'm a big lover of BitBucket pipelines and for a lot of Laravel Projects I can just use the generic PHP docker image however, this doesn't include the one thing I needed for one project which is the SoapClient. The reason I need the SoapClient in Pipelines is because PHPUnit runs tests against a WSDL API to ensure that we don't get garbage back and that the API and parser client is working correctly.&lt;/p&gt;

&lt;h4&gt;The Snippet&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;apt-get update -y &amp;amp;&amp;amp; apt-get install -y libxml2-dev &amp;amp;&amp;amp; apt-get clean -y &amp;amp;&amp;amp; docker-php-ext-install soap&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;All you need to do is add the above snippet into your &lt;b&gt;bitbucket-pipelines.yml&lt;/b&gt; file under &lt;b&gt;script:&lt;/b&gt;! It really is that simple! Your PHP docker image will then have access to the PHP SoapClient.&lt;/p&gt;

</description>
      <category>php</category>
      <category>docker</category>
      <category>bitbucket</category>
      <category>git</category>
    </item>
  </channel>
</rss>
