PHPloy – Deploy Git Repos Easily through FTP/sFTP

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 used a bash script for some times. But that script was a bit sloppy and not very user friendly. I searched again for something written in PHP and I found a great little script that worked great. I used it for a long time as-is. Then I needed it to support Git submodules, which it did not, and so I added that functionality and made many more improvements. Now again I needed it to support nested submodules, or in other words, submodules inside submodules, and now it it has that functionality in place too.

So, it seemed a great time to make that little script public. I’ve named it PHPloy, and it does very well what it says. It is a little PHP script that allows you to deploy files through FTP to a server. It makes use of Git to know which files it should upload and which one it should delete. It is a real time-saver.

How it works

PHPloy is very easy to use. After you have committed your changes in Git and have configured your server(s) in deploy.ini, all you have to do is run:

phploy

If you want to specify a server, you run:

phploy -s staging

Or the long form:

phploy --server staging

There is a lot more fun stuff that you can check in the project page in Github.

Behind the scene

PHPloy stores a file called .revision on the server. This file contains the hash of the commit that you have deployed to that server. When you run PHPloy, it downloads that file and compares the commit reference in it with the commit you are trying to deploy to find out which files to upload.

Grab it

Head over to PHPloy’s Github page to download it and learn more how to use it.

0 responses to “PHPloy – Deploy Git Repos Easily through FTP/sFTP”

  1. Arian Avatar

    What an awesome little helper tool Baki.

    1. Baki Goxhaj Avatar

      Hey, thanks for dropping by. Yes, I’m in love with it ๐Ÿ™‚

  2. Tuan Anh Avatar

    Hi, just found your blog by searching PHPloy ๐Ÿ™‚

    I have the same question using git and how to deploy changes to server. A friend of mine suggested PHPloy. Looks like it’s simple to use.

    Thanks for your post!

    1. Baki Goxhaj Avatar

      Yes, it’s build to be easy to use. Thanks for the comment. ๐Ÿ™‚

  3. Scott Avatar

    Baki, I saw your tweet on this tool, thanks for the heads up. It sounds promising. Frankly, my biggest challenge at this point is trying to figure out what to put under version control, and getting comfortable with git’s workflow. Initially I was thinking entire site, then backed down to child theme files, now considering plugins as well. The other piece beyond VC’d files is the db migration strategy. I’ve come across several tools but haven’t tried any of them yet. Setting up a new site was pretty straight forward, but now changing to a new child theme w/ mods, and upgrading an existing not yet in VC has been a lot to think/work through. Good thing I don’t have traffic…:-)

    1. Baki Goxhaj Avatar

      Hey Scott, thanks for stopping by.

      I know where you are coming from. I normally put under version control only the theme I’m working on – it can be a normal theme or a child. It gives me the flexibility to keep stuff updated through WP, like plugins and core itself.

      As for the database, I seem to just skip this step. I don’t develop the content offline. I work with dummy offline and then move online with real content. Once online, migration form staging to production is pretty easy.

  4. Nicola Avatar

    Thanks for this! It works like a charm.
    Any chance of getting PHPloy watching file changes?

    Cheers,

    1. Baki Goxhaj Avatar

      Thanks for stopping by and using PHPloy.

      For future reference, this issue was solved on Github here: https://github.com/banago/PHPloy/issues/58

  5. Chrisdigital Avatar

    Very cool. For those of you (like me) that are looking for effect models for branching and working with git. Check out this post that helped me get it understand tagging. version #’ing, and etc. a little better: http://nvie.com/posts/a-successful-git-branching-model/ Cheers!

  6. Rifky Avatar

    Hi, what is the path we need to mention inside the bat file.

    at line 20
    php C:\path\to\phploy %*

    i’m windows 7 64 bit

    1. Baki Goxhaj Avatar

      Please open an issue in Github so our Windows contributor can look at the issue. Thanks!

  7. Ben Avatar

    So so so cool !
    Thank you very much this is exactly what I needed ! The multiserver feature is amazing !
    Have a good day !
    Thanks from France !

  8. directorlector Avatar
    directorlector

    You should use phpseclib for SFTP instead of libssh2. phpseclib has a number of advantages over libssh2 including, surprisingly, speed. More info:

    http://phpseclib.sourceforge.net/ssh/compare.html

  9. Md Habibi Avatar

    Impressive!! thx alot!!

  10. Chris Avatar
    Chris

    Hi,

    it is posible to deploy only a subdirectory of my repository? Because only one folder of my repository contains the codebase for the server. But the name of this folder does not match the folder name on the server.

    1. Baki Goxhaj Avatar

      Yes, it is possible. You use the copy settings in phploy.ini.

  11. Evert Albers Avatar

    I am wondering if there is still a usecase for PHPLoy when I am already using automation via grunt/gulp/ftp?

  12. mike Avatar
    mike

    Old post, I know, but thanks for this tool. Really appreciate the work.

    1. Baki Goxhaj Avatar

      Thanks Mike, I really your appreciate it. ๐Ÿ™‚