Extremely simple deployment with PHPloy
Let me ask you a question: How mad do you get when you have to remember which files you edited and select them on FileZilla to upload to the server? That’s right – very mad. And sometimes you just upload the whole project because you don’t remember what you edited. I have four words for that: “Been there; done that”. Out of that frustration I set out to find a script that would use Git to determine which files I had edited, since this is what Git does best, and upload those to the server through FTP.
I think everbody can agree to this statement of Baki Goxhaj on his blog WPlancer. Deployment, the process of moving your (updated) code to the live server(s), is something everybody has to deal with, but only very advanced people do it in a professional way. I’ve seen web agencies with 100+ employees, most of them developers, releasing stuff with pure drag & drop FTP. Ouch! Unless you are ready to work with professional tools like Jenkins or Capistrano try this tiny tool that totally does the job:
PHPloy is just a simple PHP file run on the bash (plus a config .ini) that copies all changes from the last deployed commit to the defined server. One command on the command line. Rollbacks are also possible, with one line of code. The configuration of a server is… well, one line of code. Super-simple, super-effective. I love stuff like that!
A basic workflow (advanced ways are possible too)
Put PHPloy (bash file with pure PHP content and .ini) into your project’s root.
Edit the .ini and put your FTP credentials in there and name your server(s). It’s possible to use lots of servers.
[quickmode] staging = ftp://example:email@example.com:21/path/to/installation production = ftp://example:firstname.lastname@example.org:21/path/to/installation
Run a deployment via
to deploy to all servers defined in the .ini (normally just one) or use this line to deploy to a certain one:
phploy --server servername
Done. Please make sure you never put the .ini file into a public place accidently as it holds your FTP credentials.
For rollbacks use
to get back to the last deployed version.