I've been working on PHP web apps for years, and over time, my development workflow has remained fairly constant:
- Configure new app in apache/nginx
- Starting coding to find out my environment is broken
- Fix my environment
- Continue coding
- Get bored
- See step 1
Managing DevOps items when I should be focusing on building a product is not beneficial to my productivity.
Enter Vagrant.
Ever wanted to have a dev environment built for you automatically? Yeah, who doesn't? Vagrant can do that for you. With the help of Oracle's VirtualBox, Vagrant creates a virtual machine, can provision it with the packages and services you define in a text file, and creates helpful links in between your host OS and the guest OS.
Phalcon PHP
I need to write another post entitled "Phalcon is Awesome". I've only recently started to develop with the C-extension based PHP framework, but boy does it pack a punch. One phrase before I do a write-up: ~800 requests per second.
The only downside of using Phalcon is having to compile and load it for use by PHP. git clone
-ing the cphalcon repo and running the build script is easy enough, but what if you're getting help from a creative that has no idea how to set up a virtual host on their local machine, let alone compiling a PHP extension?
Use Vagrant, of course!
I've been using Vagrant to host a Phalcon project for a while, and I managed to extract out the Vagrant goodies into a stand-alone project: vagrant-phalcon. With the help of a Puppet manifest and a bash script, vagrant-phalcon helps developers of all skill levels start with Phalcon with an easy vagrant up
command. Details from the README.md:
Getting Started
- Download and install VirtualBox
- Download and install Vagrant
- Clone this repo
- Run
vagrant up
in the repo directory- Visit
http://localhost:8081/
in your favorite browserNote
Nginx is configured by default to use
./src/Public/
as the root directory. If your public directory differs, be sure to update theVagrantfile
to reflect your needs.
While not perfect, it does the job of setting up a Phalcon dev environment quite well, so I felt content with releasing it out into the wild. Happen to find a problem with it or have a suggestion? Submit an issue, or better yet, submit a pull-request.
Here's an ascii-cast walkthrough: