So I’ve been using Devilbox as my local dev stack for a couple of months now and I’m more than comfortable with it, having used it for WordPress and stand alone PHP application development. It’s quick and flexible and doesn’t seem anywhere near as flakey as my previous WAMPserver set up. I thought it was time I took a look at some other PHP frameworks, in particular if there were any issues in getting them to run in Devilbox. I tried Expression Engine, under a recommendation from someone – breezy installation, not quite as easy as WordPress but I’m still looking to see if there are any tools I could use to speed that up; it looks like a solid CMS and is now open source so well worth checking out – expect a post about that in the future!

One thing I did want to look at getting back to, however, was picking up MVC development in PHP. One of the more popular posts on this blog over the last year has been this one about running Symfony on WAMPserver, so I thought I’d take a look at getting it up and running on Devilbox. Initially I tried using the instructions I’d written way back in February of last year, but I couldn’t get it working due to the way Devilbox dynamically assigns virtual hosts. Fortunately a quick Google later and I found actual approved Devilbox documentation for getting Symfony up and running – it is, however, a little out of date and required some working through. I’ve decided to provide my own little step by step right here!

1. Get Composer installed

Not got Composer? You’ll need it! Get it installed here.

2. Create your Devilbox vHost folder

Head into your devilbox/data/www folder (or whatever path you’ve installed your container into) and create a folder for your project; we’ll call ours symfony-project as an example.

3. Install Symfony

So far, so much like the official documentation, but here we’re going to start to deviate slightly.

Pop open your command line, navigate to your root devilbox folder and and hit up Devilbox’s local PHP environment:

Linux: ./shell.sh
Windows: ./shell.bat

This will handily drop you into your webroot so you only need to cd one level into your Symfony project folder and install Symfony in there:

cd symfony-project
composer create-project symfony/skeleton symfony

This will start Composer installing Symfony into a folder called symfony within your vHost root.

You’ll notice that the command to do this is different from the official documentation. I couldn’t get that working but Composer worked fine.

You’ll also notice that we don’t have a htdocs folder in our vHost root, like you’d expect from Devilbox projects. This is where the next step comes in!

4. Set up a symlink for the webroot

So this is what was stumping me when I was trying to get Symfony up and running by myself; telling the Devilbox vHost that the webroot is infact NOT htdocs, but the root folder within Symfony. Again the instructions differ here as they refer to a web folder in the Symfony project – this is now called “public”. So, to set up the symbolic link to tell Devilbox where the webroot actually is, we need to enter:

ln -s symfony/public/ htdocs

5. Set up your DNS

The instructions say to enable Symfony prod, however I found that wasn’t necessary and likely out of date. So, head over to your hosts file and add an entry for:

127.0.0.1 symfony-project.loc

6. Open your new project in a browser

Head to http://symfony-project.loc in your browser of choice and bask in the warm glow of the Symfony welcome screen! Congratulations, you’re now ready to build your project!

All in all that’s a fairly straightforward and, dare I say, easier process than the one I outlined in my WAMPserver article. You don’t have to faff around installing the Apache module into your project, and Devilbox handles all of the vHost definitions for you. All you need to do is remember to set up the symlink to tell it where the webroot is and you’re gold!

As always, hope this helps! Drop in a coment if it does or if you’ve got anything to add here!