<?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 Ed Perkins on Medium]]></title>
        <description><![CDATA[Stories by Ed Perkins on Medium]]></description>
        <link>https://medium.com/@edperkins_91741?source=rss-b8285c7d41b3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_SQ8_TBwAWA1XAQV.</url>
            <title>Stories by Ed Perkins on Medium</title>
            <link>https://medium.com/@edperkins_91741?source=rss-b8285c7d41b3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 22:34:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@edperkins_91741/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[Setting up a TDD development environment for PHP, Apache and MySQL on a mac (for total noobs like…]]></title>
            <link>https://medium.com/@edperkins_91741/setting-up-a-tdd-development-environment-in-php-including-ubuntu-server-on-a-mac-for-total-noobs-bae760dc8730?source=rss-b8285c7d41b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/bae760dc8730</guid>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[virtual-machine]]></category>
            <dc:creator><![CDATA[Ed Perkins]]></dc:creator>
            <pubDate>Tue, 17 Apr 2018 20:19:45 GMT</pubDate>
            <atom:updated>2018-04-20T08:58:00.199Z</atom:updated>
            <content:encoded><![CDATA[<h3>Setting up a TDD development environment for PHP, Apache and MySQL on a mac (for total noobs like me)</h3><p>Today I spent quite a lot of time figuring out how to do this so I thought it might be helpful to write a guide for others wanting to do the same. This applies to vanilla PHP as well as Laravel and Yii. This guide also includes how to install Ubuntu Server on a virtual machine.</p><p>It’s a pretty dry sequence of events so I’m going to pepper it with images of 80s hair metal artists for absolutely no reason whatsoever, along with some obviously fabricated factoids about software languages that weren’t even around in the 1980s.</p><h3>Managing packages and testing</h3><p>There are a number of other things I learnt about PHP today that may also help you:</p><ul><li><a href="https://getcomposer.org/download/">Composer</a> is your package manager, like Homebrew, NPM in JavaScript or Gem in Ruby (don’t use PEAR, trust me). <a href="https://www.sitepoint.com/re-introducing-composer/">Here’s</a> a guide to installing it, it uses a json file within your project. Like NPM you can install it globally or on a project by project basis.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*cOx0ZjnvunMZnBYwKJlwTQ.png" /><figcaption>Dee Snider from Twisted Sister attempted install PHPUnit using PEAR and it caused him to rip up part of his shirt in anger and turn it into sort of gloves for his tired fingers.</figcaption></figure><p>You’ll need Composer to install testing software, although Laravel and Yii will write their own tests to some extent, a bit like Rails.</p><ul><li><a href="https://github.com/sebastianbergmann/phpunit">PHPUnit</a> seems to be the de facto testing environment. If, like me, you prefer to install your testing framework in each project, you can use your composer.json file to require it. There are some instructions on how to do that on <a href="https://phpunit.de/manual/6.5/en/installation.html">this page</a>.</li></ul><p>This is where I started to come unstuck, as PHPUnit requires PHP 7.1 or above, and Macs have PHP 5.5 installed by default. Obviously, you can upgrade your PHP, which I did although it was fairly time consuming to get my mac to use the right version. You’ll also need to update Apache to run your server and MySQL to manage your database on any project that needs one. You’ll then need to update them all over again if you do a system update and everything gets overwritten back to the default versions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*LqyUK4uNuq-Yh_y9-FMM7g.png" /><figcaption>Duck-faced magnet Bon Jovi (real name John Bovey) created PHP during a particularly indulgent and extended Richie Sambora guitar solo on the ‘Slippery When Wet’ tour of 1986</figcaption></figure><p>Also, there are apparently some issues with finding, running and building certain custom PHP extensions natively on OSX.</p><p>I also had no idea what to use as a server to run my apps in a browser, the most common approach seems to be to use XAMPP. A developer friend of mine suggested creating a VM (Virtual Machine) which would solve all of the above issues.</p><h3><strong>Installing an Isolated Development Environment</strong></h3><p>The best solution, and one that would give me a development environment that would be close to production, seemed to be to use Ubuntu. Using a VM would also mean that I could eventually have multiple development environments set up for dealing with specific project requirements.</p><p>I used <a href="https://www.virtualbox.org/">VirtualBox</a> which was fairly easy to install, although I had some security issues with Sierra which caused the installation to fail. Eventually I got around it by following <a href="https://apple.stackexchange.com/questions/301303/virtualbox-5-1-28-fails-to-install-on-macos-10-13-due-to-kext-security">this</a> stack overflow post, and restarting my Mac.</p><p>The next thing you will need is <a href="https://www.ubuntu.com/download/server">Ubuntu Server</a> which downloads as an .iso file.</p><p>I found this really simple video tutorial on <a href="https://www.youtube.com/watch?v=ZMXNXvwvhcs">how to install Ubuntu Server in Mac OS X</a> after trying out a lot of other tutorials including some which used Ubuntu desktop, this is not the way to do it apparently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*ydij2sY9Hz6_dfsaOCfTJQ.png" /><figcaption>Top Vixen track ‘I Need That’ was famously written as an ode to PHP package manager Composer</figcaption></figure><p>The good thing about this tutorial is that it shows you how to link the VM to your terminal via SSH so you don’t actually have to interact with the VM interface once it has been set up and updated.</p><p>One thing it doesn’t mention is how to set up a shared folder on your hard drive that you can access from the VM. This means that you can run your projects on your server, but keep editing them in your favourite code editor (I am partial to Atom, but sometimes envious of Visual Studio when I see others using it)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*brEFSQ51mSG4C_HqkcLdjg.png" /><figcaption>Coiffeured songsters ‘Poison’ eventually split due to unresolvable differences over wether to use a light or dark theme in Atom to best match their bouffant hair dos.</figcaption></figure><p>You can do this by going to your VM settings in VirtualBox and adding a shared folder. Your folder should then be accessible through your VM, or via terminal at /Media/sf_&lt;the name of your shared folder&gt;</p><p>Mine wasn’t, so I had to install Guest Additions to be able to mount the folder (I had already chosen auto-mount when setting up my shared folder):</p><ol><li>Start your VM</li><li>Devices &gt; Insert Guest Additions CD image...</li><li>I had to manually mount the CD: sudo mount /dev/cdrom /media/cdrom</li><li>Install the necessary packages: sudo apt-get install make gcc linux-headers-$(uname -r)</li><li>Install the Guest Additions: sudo /media/cdrom/VBoxLinuxAdditions.run</li></ol><p>To permanently mount your folder you should add the following line to /etc/fstab (sudo nano /etc/fstab):</p><pre>New /home/user/new vboxsf defaults 0 0</pre><p>Where ‘New’ is the name of your shared folder. Obviously you should replace user in /home/user/new by your own username.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*sCZfNl52mwl99mBoDMAMNA.png" /><figcaption>Mötley Crüe get really shocked and upset if you use anything other than Vim</figcaption></figure><p>I could then see the folder at /Media/sf_New, but still got a a permission denied message. Finally I had to add my Ubuntu user name to the vboxsf group in the terminal like so:</p><pre>sudo adduser xxxxxxx vboxsf</pre><p>After a lot of searching , I finally had a virtual Ubuntu server up and running with Composer installed, ready to install PHPUnit on my PHP projects.</p><p>If you want a quick tutorial on how to write tests in PHP, I used <a href="https://www.sitepoint.com/re-introducing-phpunit-getting-started-tdd-php/">this one</a> from Sitepoint which is a good starter.</p><p>Hopefully that saved you some time, good luck PHPing!</p><p>Thanks to <a href="https://www.mutantsounds.com/info/about">Jason Dixon</a> for pointing me in the direction with a lot of this</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bae760dc8730" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>