Adventures in DevOps & Coding: Learning PHP & Setting Up Continuous Deployment


· · · ·

Face it, if you are a born and raised .NET Client/Server developer like me, you are now old school.  I have been aware of this fact for several years now, but not until late 2013 did it start bothering me.  Now it’s 2014 and it’s time to refine my skills.  This post is on how I quickly learned basic PHP, jQuery, and web dev.  And finally a little bit on the concepts of DevOps.

Visual Studio makes me comfortable.  C# is like a warm blanket.  When I think about other programming languages, especially those used to create web applications, my heart races a little.  But it’s time.  So I decided to pick up a little PHP.  Why PHP?  First of all the foundation of the language is still object oriented, even though it has a scripting feel too me, the syntax is somewhat comfortable .  Also because it is run server side, it made complex applications i’m interested in possible.  Those were the technical reasons.

On the personal side, the big reason is I have several friends who are PHP coders, and it’s just a really popular language that has found it’s foot hold.  I could have taken a more radical approach with brande new languages, or dive in the world of mobile dev which has aspects very similar to Client/Server Dev, but many things that are just totally different.  The reason I did not was because the vast majority of the application world is consist of web applications, counting all those applications that support mobile applications.

The better question is why did I not take up .Net web dev?  While I’ve created several .aspx style applications, and I still believe that Visual Studio is the best IDE out there, I get really frustrated by all the baggage and bloat that comes with .Net applications.  And I wanted to enter an uncomfortable territory.  So PHP it is.

To learn PHP I spent several hours on  An excellent website for learning several of the popular web dev languages. Plus you earn badges which always makes me feel good.  My goal was within a few days to write a simple, none ‘hello world’ application.

<math nerd alert, it will go fast I promise> I choose to do an implementation of genetic algorithms (GA) which I was already familiar with.  Forget the cool name, GA is just an algorithm that rapidly evolves a set of critters. And each generation of critters is evaluated against some criteria.  The assumption is that you can easily evolve critters quickly to solve some problem, versus explicitly solving the problem.  Real world applications for solving complex equations using GA are very cool, but mine is stupid simple. For my application I simply wanted to see how quickly ( number of generations ) I could evolve random critters consisting of binary strings to match ( converge ) on the ideal binary string I give as input for example ‘11111111110000000000’.  </math nerd>

Don’t get hooked up in the application, GA was a study of mine in collage, and I really latched onto it.  Rather focus on the fact that, i’m now creating a simple web application from what i’m used to creating as a heavy Win32 one.  It requred classes, methods, and real OOP.

Because this was going to be a web application, and I wanted some, albeit archaic, visualization, I also needed learn/refresh jQuery.  I found great lessons for this on CodeAcadamy as well.

After I felt comfortable with the concepts of creating objects, variables, functions, etc in PHP.  I was ready to build my application.  I needed to choose a source repository, and an IDE.  Now I know you heads down coders laugh at the idea of an IDE and rather do everything in some decked out Text Editor.  That is cool and all, but i’m addicted to syntax checking, highlighting, and dot completion that I get with a good IDE. I will sacrifice looking cool for the time savings of a good IDE. It was not easy to hunt one down, but I did finally land, for now at least, with PhpStorm from NetBrains.  Which seemed to have the features I was looking for.  Meanwhile i’m contemplating moving to a Cloud based IDE, as I believe they are the future, as you may have seen in my year end post.

Screenshot of Cloud IDE

Screenshot of Cloud IDE

For the source repository, I was not going to think too hard about it. If it was a .Net app I would have used TFS services now Visual Studio Online.  But i’m going to go the common path of GitHub. So I created an account, created a repository, and the nice thing about PhpStorm, is they have an integration with GitHub.  Enter your credentials, commit code, push code.  Very easy.


So I wrote my basic application that runs through generations of “critters” and evolves them until they match the “ideal critter”.  I wrote several classes, and I started to feel like a real PHP programmer.  I got everything setup on my local machine, but it is now time to test out this Continuous Deployment stuff, and have my application automatically deploy somewhere on the public web.  It is really convenient to be able to access the application on my local machine, but the power is publishing web applications for the world, right? No surprise here, I turned to CloudShare as my infrastructure.  The setup for now is simple, a single web server.  Later I will go back and separate the backend server, and a failover server for a more complex multi-tier application.

First thing I needed to do was create the environment.  As you may know setting up an environment with networked VMs in CloudShare is simple.  Select your machines from the template library, click, click, they are provisioned.  I created an environment with Windows Server 2012 64-bit Standard template.  Though it is a PHP web application, I really like the administration UI of IIS so i’m partial/still old school about this.  And this particular Windows template is ready to go with PHP 5 installed and configured in the IIS with appropriate default document and handler mapping for PHP.

Once my server was provisioned, only 5 mins, I then needed to make sure web access was enabled.  Web access is the way to give public access to the web application hosted on your VM.  To enable web access on your CloudShare VM, in your CloudShare account click on the Edit Environment -> Edit Users and Access Button.


Here you will see a check box “Enable Web Access”.  Check that bad boy and save the changes.


What this will do is allow incoming internet connections to resolve to the web server on your VM.  By default it goes to port 80, but CloudShare has 10 other ports available as well.  This feature will also generate for you a unique static URL that you can use to access the VM.  This is great for user acceptance testing ( UAT ), and sharing with people to see your application from any browser.


For now when I click the URL I get the default IIS 8 page.  But I will fix that soon.

Now, I need to install Git on the VM.  I like Git for Windows as a client for accessing my GitHub account.  It offers a simple UI, creates the home path for git to be accessed via command line and sets up a nice context menu for folders to quickly access Git Bash. After it is installed I make sure I can access the Git command from command prompt.


To setup auto-deploy from GitHub you have to do a few things.  You first need to create a hook in your GitHub account that points to the destination URL in your application.  GitHub will push (“POST”) code after a successful commit+push has happened from the IDE/Developers machine to this URL.  But for the Push to work you need to have some sort of listener on your server.  For this I found, and am using gitdeployhub.  It is an open source ASP.Net application that will accept POST from GitHub and put the code where you want.


It also has options for running deploy scripts after the files have been transferred.  So you could run a powershell script to refresh a database, or restart IIS.  My application is not that advanced so no scripts needed, but an important feature for any real deployment. To install GitDeployHub I get to use my newly installed GitForWindows to pull it down from GitHub, and do some IIS configuration.

[code language="Text"]
 cd C:\Inetpub\wwwroot
git clone git://

Will pull down the package and copy it to the wwwroot path. Now just one additional step to tell IIS that the application exists. I open IIS management console, and convert the /gitdeployhub/web path to be an application.


For me it was that easy, but if you are doing this outside of CloudShare you may have to work on your permission settings to make sure that there is read/write access to this directory by the default IIS user, and that ASP is enabled as a feature under IIS.

Once it is all setup you have a very basic web interface at http://localhost/gitdeployhub/web, to view the status and do manual deploys.


On the GitHub side login to your account.  Open the repository you are working with.  Click on ‘settings’. Click on ‘Serivce Hooks’. Click on ‘WebHook URLs’. And enter your Web Hook URL.  This will be your web access URL generated when you turned on the feature plus the path that accepts deployments.  For example:


This will tell GitHub where to push your code after an update. That was it!  My code was being deployed, I could access the application from my CloudShare VM Web Server, and every update was being pushed.  It wasn’t fancy, but it was a good holiday break accomplishment.


Now that I feel so accomplished, I will start tackling more complex infrastructure setups with deploy scripts with more complex infrastructure with separate front ends, and database servers.  The nice thing is that in CloudShare even if the infrastructure gets more complex my effort stays the same.

To my surprise none of this adventure was complex.  I was prepped for some temper tantrums and restless nights because I get stuck. I  especially expected the DevOps side of it to just fry my brain, but because I had handy the CloudShare environments, and a VM template already to go for deploying.  My first published web application was simple simple.  If I wanted to I could now even add the infrastructure elements to the application itself so that during deploy it actually creates the environment as part of my code.

I can now put the grandpa Win32 applications behind me.

is a bad-coder-turned-technology-advocate who understands the challenges and needs of modern engineers, as well as how technology fits into the business goals of companies in a demanding high-tech world. Chris speaks and engages with end-users regularly in the areas of modern AppDev, Site Reliability Engineering, DevOps, and Developer Relations. He was one of the original founders of the developer marketing agency Fixate IO, and currently works as a Sr. Manager in HubSpot’s Developer Relations team.


Click on a tab to select how you'd like to leave your comment

Leave a Comment

Your email address will not be published. Required fields are marked *

Skip to toolbar