Let’s talk about deployment.

The past

Several years ago when I wanted to deploy an application I did it using FTP. Filezilla was the best friend. When some feature was ready I connected with the server, copy files into proper locations and it was it. The application simply used new files from the next request.

Easy? Not at all. It was annoying to connect the server, find directories and copy new files. It was very easy to make a mistake and copy file into the wrong directory.

And it was in times when I don’t even know that version control systems exist! That means that I have the newest version of edited files on my computer and on the server only. When I worked on a project alone it was “only” risky. But I remember one project on which I worked with 2 other people in the same time. You know what it means, don’t you? 😉

When I wanted the newest version of the file I had to download it from the server! And if I worked on the same file as someone else (and of course I did…) it was easy to override someone else changes (what of course happened a lot…). The production application was, in fact, our version control. Creepy.


Thankfully that hard times passed. On another project, we have used SVN which helped us to synchronize work on the same project. It kept all our changes and all versions of every file. And if I changed a file that was earlier changed by my coworker I only had to merge conflicts. Overriding someone else work happened very rarely.

But the ugly way to deploying the application was still the same. Connect to the server and copy necessary files. In fact, I have done it this way in my one and only serious project in .net! 😉 Bad behavior is universal…

Capifony FTW!

When I started to write in Symfony2 framework everything changes. I learned about Capifony. Capifony uses Capistrano – deployment tool for Rails apps. It has recipes specifically to deploy Symfony applications.

All technical information you can find on the official Capifony website, but I’m gonna describe how it works and what it do to simplify deployment.

In the simplest configuration, Capifony gets application’s code from some version control system, Github for example. First, it creates new release directory, then downloads any dependencies specified in `composer.json` file (see PHPyths Buster: a few words about importing classes) and warmups the cache. When everything goes fine it changes `current` symlink to the new release and… that’s it. From the next request, the application uses the new version of files! And that all happens by simply calling `cap production deploy` command.

Capifony is highly customizable. You can specify additional tasks to do during deployment (want to send the e-mail to the boss when the new release is deployed? – no problem). By default Capifony keeps 3 versions of the application, so if anything is wrong with the new one you can always return to the previous one. Once again – if you want more information – http://capifony.org/ 😉


From the old and ugly techniques to deploy an application, we go to very handy and reliable one. From FTP and only locally keeping the project through SVN and FTP to Capifony and fully automated way to release an application.

Once again it appears that PHP is the modern and comfy language for making modern applications!

What’s next?

In previous posts, I’ve described some tools that make writing in PHP cool. To show you the full potential of it in the next posts I’ll be writing simple Symfony application. I’ll describe all steps from setting up the environment through tools, installation to deployment. It’ll be complete example that you could use to learn modern PHP.

The project will start soon, so remember to check out my twitter!

Don’t forget to check out other PHPhyts!