PHP Apps and Platform as a Service

cloud-computing2Recently, I saw a tweet from @JuanTremino about moving a website out to AppFog.  So first things first, thanks to Juan for the inspiration for this post.  I have been meaning spend a little time looking at a few different Platform as a Service (PaaS) providers and check out what they have to offer.  There are several options out there for PHP apps using this medium for deployment, and picking one is not always the easiest thing to do.  The most interesting thing that I noticed about the various PaaS providers that I looked at was they way they differentiate their pricing models.  From a business standpoint, differentiation is great, it provides a vehicle to set yourself apart; however, for the consumer things can get hazy and confusing in  a hurry with so many choices.

With Infrastructure as a Service (IaaS), hosting, VPS, and related services, direct comparisons are pretty easy.  In reality the number of options that matter for a hosting account or VPS are relatively finite.  The PaaS providers do not make the choice nearly as simple.  Each of them has different options to consider and different terminology that describes their particular product offering.  Here are some examples.

  • EngineYard Orchestra:
    • Autoscaling vs. no Autsocaling
    • Custom Domain vs. Orchestra Subdomain
    • Free or Free and Paid Add-ons Available
    • Shared vs Dedicated Resources
    • Number of Concurrent Connections
    • Max number of Applications
  • PagodaBox (
    • Number of Applications / RAM per instance
    • Number of Databases
    • Caching
    • Workers (run tasks based on various conditions)
    • Bandwidth
    • Writeable Storage
    • Encryption
  • AppFog (
    • RAM
    • Number of Service Instances (SQL, MongoDB, Redis, etc.)
    • Storage per Service Instance

What also varies from platform to platform is how you move your app into the server.  Some services like EngineYard use a git or svn repository.  Appfog uses an upload process via command line interface.  The bottom line is, you have to do some digging and find the solution that suits you the best.

For this tutorial, I am going to demonstrate deploying the Lithium framework onto a free account from AppFog.  The reason I chose AppFog was really just the simplicity of their offering, and the fact that I could wire in my own domain name.  I would have preferred to use a solution that was compatible with git, but all things being equal, I found the AppFog console and documentation to be straightforward and easy to understand.

STEP 1: Set up your free AppFog account and get logged

STEP 2: Set up your application.  The Interface is very clean, requiring you to only select the platform, location, and provide a name for the application.  The screenshot below shows the platform options, which vary from Java, Rails, or PHP to WordPress or Drupal.  The nice thing about this is that if you are doing a WordPress or Drupal site, then your setup is really simple.  In this case, I am going to install PHP.

Screen Shot 2013-01-05 at 9.33.53 PM

STEP 3: Let’s assume for a minute you will need a database connected to your application.  In this case, you will need to add & bind a service to your application from the AppFog web console.  You can do this by clicking the Services item on the menu and choose the service you want to install along with a name for the service, as shown below.  The connection parameters are stored in an environment variable that you can use in your app to make the connection to the service.

Screen Shot 2013-01-05 at 9.58.43 PM

STEP 4: You need the command line tools.  AppFog provides a detailed tutorial on this, but really and truly, it is a matter of running 3 commands in a terminal window.  There is a Ruby gem installation, then you simply update your gems, and login to AppFog on the command line.  A word of caution, when installing the gem, the terminal window seemed to sit idle for a minute or so, with no indication it was doing anything, so just be a little patient. A screenshot of part of the installation process is below.  The installation guide is located at:

Screen Shot 2013-01-05 at 9.45.20 PM

STEP 5: For my demo, I wanted to wire it into my own domain.  This is also done from the AppFog web console, and is as simple as filling in a single field.  Obviously, I also had to do a DNS edit and insert a CNAME entry.  This step is not needed, you can use the default subdomain that AppFog provides (e.g. ).

Screen Shot 2013-01-05 at 10.07.29 PM

STEP 6: Assuming you have set up your Lithium application and are ready to upload it, the process is pretty simple.  From the command line, navigate to the directory where your project is stored and enter af update lithium   (lithium is the name of my app).  You should see the following:

Screen Shot 2013-01-05 at 10.16.06 PM

STEP 7: If your application uses a different document root other than the main directory, like Lithium and many other frameworks do, there is one other step.  You have to setup an .htaccess  file in the project’s root directory (the one that contains /app  and /libraries  directories) to redirect into the correct path for your application.  In the case of Lithium this is the /app directory.  Below is what needs to be in the .htaccess file:

There are 2 things that in my opinion would really make this a fantastic platform to work with.  First, I would love to see git and svn worked in like some of the other PaaS providers.  It would really be nice to be able to commit and push straight from my IDE.  Second, having to put the .htaccess file in feels a little bit hacky to me.  Being able to set the document root from the web console would be a great addition.  I believe EngineYard provides that functionality, if I am remembering correctly.

That’s really about it.  I set up the site at as place to do some testing and exploration of the framework.  Overall, I have to say that Juan was correct, it was very easy and kind of fun to experiment with a new type of platform.  Hope you find this useful.  If you haven’t worked with a service provider like this in the past, it is probably worth a little time to get familiarized.  With a process this simple, it is not hard to envision that these platforms will become increasingly popular as time goes on.





, , , ,

  1. No comments yet.

Comments are closed.