When you have plenty of Symfony2 applications and you need to deploy them from time to time, you are probably sick of thinking about every activity you need to do for every deploy. Often people use some build scripts, which are hard to maintain and tends to be unreadable. I wanted to automate it as much as it possible and I’ve choosen Ant, to help me out.

Actually Ant is choice, due to other fact – it can be easily used with Continous Integration server like Jenkins, while ssh scripts often generates some problems. With this aproach all you need to have Ant binary on server and build.xml config in root folder. You can have different targets defined in config and chain them using depend attribute. So in this case you can have target for building project on production server (usefull for continous delivery) and setup for Jenkins.

Below you can see my build.xml file. It basically pulls latest changes from Git, installs Symfony2 vendors, runs script to fix cache permissions, removes cache, dumps assetic files and install static assets.

It works for me and does everything what is need to be done during deployment. To run deploy just type ant in root folder. You even don’t need to go to the server, just type from your terminal:

For more sophisticated deployments tasks you should probably have a look on capifony.