I am always searching for new ways how to automate and simplify my work. When I started using Git, it was a giant step forward for me, but it didn’t solve the problem of deploying files to the server, because where I work, the vast majority of web hosts don’t provide SSH access. Therefore, when I wanted to push the files to the server, I still used FTP, which is a pain in the ass, because I am never really sure if I uploaded all files and/or if all these files uploaded correctly (I am looking at you, Total Commander). In fact, I only heard of the term deployment when I started using Git. I got into the situation where I use Git to my satisfaction, mainly as a form of backup (which is of course only a fraction of what Git can do, but to me it’s enough for now). I read all those articles about using Git hooks for deployment and I thought “how can I use this without the SSH access?”
During that time, I bought PHPStorm. Before that, I worked with “ordinary” text editors, mainly Sublime Text and Notepad++. I didn’t see any advantage by using a full blown IDE. I realized how wrong I was the moment I noticed how much faster I work when working in PHPStorm – it just felt natural and very convenient. I would say that the main advantage is that everything is in one place. It took me a while to configure all the keyboard shortcuts I used in Sublime Text and get used to the other ones, but the fact that I have everything right before my eyes and I don’t have to be Alt-Tabbing all the time is great (I have two monitors, but still…).
Anyway, I was looking for a way to eliminate the need to use FTP and PHPStorm helped immensely with that. Coincidentally, I came across this article, which helped a lot. It’s really simple – when you commit, you can start an automatic deployment of changes files via FTP / FTPS / SFTP. No need for SSH, no additional overhead. For my needs, it works perfectly and saves me a lot of time and nerves.
Using PHPStorm to deploy over FTP
It’s really easy. When configuring deployment (Tools – Deployment – Configuration), enter the FTP server details:
Then you might want to edit the paths to suit your project:
And then, when commiting (VCS – Commit changes), select your server in the “After commit” section:
Now, when you launch the commit, the modified files will be deployed to the server. Perfect.
My workflow is now easier – I am working on a project, editing files, launching tests and doing other bunch of stuff. When I feel like it, I do a commit without the deployment (I select “(none)” in the “After Commit” section). When I am done with the work, I do a “final” commit and select to deploy the modified files to the server. This way, I have my work always backed up on BitBucket and at the same time, deployed on the live server without the need to use FTP. Of course, large media files, videos etc. are not included in the repository, so these files are still uploaded manually by FTP or rsync, but it’s still much easier than before.
The advantage is that this works on the ordinary shared hosting plans (the vast majority of my clients are still using them).