How best to sync to remote after local development
I'm trying to set up a workflow roughly as follows:-
- clone remote git repo to a local directory
- sync those local files with a local (ie same filesystem) apache docroot
- have those two local directories stay in sync whenever I edit a file (in the cloned git repo)
- sync changes back to a remote server when I need to test on that server (or deploy)
I've got 1-3 working perfectly, but I can't figure out how to sync to the remote server.
- I can do deployment->upload to, which works fine, but takes forever as it seems to be re-uploading everything.
- Right clicking on a file/dir in project files and selecting 'sync' doesn't seem to do anything
- Right clicking on a file/dir in the remote host also takes a long time, gives me more detail than I normally want, and doesn't seem to just give me a simple way to mirror local files to remote
So, currently I use a shell rsync command to do the sync which works perfectly and takes only a few seconds to run... but isn't in PHP Storm and means I have to set up rsync scripts for any syncs I want to do.
Is there a simple way to achieve this in PHPStorm, so I can just right click on a file/dir in a project and have the appropriate remote host quickly mirror my local files?
Thanks,
mark.
请先登录再写评论。
After some help from support and some trial and error, I've figure out a passable way to do this using 'external tools' as described here.
I created a command line script (see below) in PHP and set up the external tool to run with the following parameters:-
"$ProjectName$" "$FilePath$" "$FilePathRelativeToProjectRoot$" "$ProjectFileDir$"
In every project where I want to rsync deploy, I create a file at the top level of that project called remote.deploy, with contents such as:-
Then I can right click on a directory in the project navigator and select the rsync external tool script. It assumes that rsync is over ssh using a key. I'm doing this on a mac and the key passphrase is in my keychain... YMMV on other systems.
It works... most of the time. The biggest problem I have is figuring out what all the parameters actually are - I couldn't find any detailed documentation describing them all.
The script will probably need some tweaking for other systems, but I hope this helps others, and I really hope rsync deployment is built into PHPStorm before too long. It seems I'm not the only person missing this.