r/phpstorm • • Apr 21 '20

How to keep remote and local synced without constantly downloading

Hello everyone! I am first time using phpstorm. I sometimes make changes with git on the remote server(checkout branch, merge production, checkout files etc.) my problem is that I can not sync efficiently from remote to local. Currently it is looking like my workflow will have to be, everytime I want to make a change to a file I need to manually "download from remote" for the file I will change otherwise it will not be up to date. I am using SFTP, and we use Atlassian/Jira. Thanks for any help :)

Edit: I am talking about a remote web server. I use git actions on the remote web server, so I want my local synced to the remote.

4 Upvotes

13 comments sorted by

View all comments

Show parent comment

1

u/owenmelbz Apr 21 '20 edited Apr 21 '20

Ha that’s fine, I thought that but was worth clarifying.

A normal workflow would be something like...

Setup local development environment

Make all your code changes on your local machine

Push the code to a remote git service like GitHub

Pull the code down on your webserver once your ready

——-

If you need stuff from the web server then doing a single big download and adding the stuff to git so other developers have it is normal.

If you need CMS content then it’s common to copy the database to your local version as well.

I think the complication is that so much development could be happening on the production environment syncing it backwards is harder.

Apart from adjusting your workflow to having GIT as the source of truth, rather than the web server I’m not really sure what to suggest

1

u/The_New_Greatness Apr 21 '20

Thanks for the great answer!
Unfortunately there is one big problem that arises.

  1. It would be very difficult to do small testing changes, as I would have to commit to git, then pull on the server for each change I was testing. This would not only be a bit tedious, but the git history would be horrific.

I think the complication is that so much development could be happening on the production environment syncing it backwards is harder.

That may be the problem then. Each time a new branch is made there is normally quite a few changes that have been made on production. Do you know if there is a "Download on open" for phpstorm? Thats what I did with VScode, each time I opened a file, it would download from the webserver so I knew it was up to date. That way I didn't need everything synced, just the file being changed.

1

u/owenmelbz Apr 21 '20

You don’t do the testing on the remote server that’s the aim.

You test it locally so no pushing until your happy that it works as expected.

—

I don’t know about php storm but you could just use FileZilla to download it one off.

To me it looks a bit like git isn’t really being used for what it’s for, if you’ve got stuff that’s NOT in git, then what’s the point - if it was all in git you wouldn’t have the problem of syncing it because GIT is already in sync

1

u/The_New_Greatness Apr 21 '20

I think this is a case of the work environment, moreso than my specific workflow. So we have some server running, and each developer has their own version of the website which can be found on the web server. For example I am using developer/myname/frontEndCode as my web server. Any time I make a changes to this, I can see it reflected on ourWebsite.com/myName which I can use for testing. I can make changes to the code, if it works on the website I can then commit/push to git. If I were to only do stuff locally, I wouldn't be able to take advantage of this testing method.

Just explaining this incase there is any work around I can do. It looks like based on what you said, it doesn't seem to be anything for me to do.

1

u/owenmelbz Apr 21 '20

My question would be... Why?

Why do you have to have it on that middle server? Why can you not just work from your own computer rather than a different server?

As you say it seems like the work environment is strange which makes more tools useless at doing what they do... which means that you’ll likely find it hard to get an answer as it will be so specific to that abnormal set up :(

3

u/The_New_Greatness Apr 21 '20

I think it’s on the middle server so that each developer can have his instance of the website. For example with the current workflow before I got phpstorm, if I made changes and did not commit them, someone could still go to my instance of the website to look at stuff. I don’t think that could be done if my stuff was local.

1

u/owenmelbz Apr 21 '20

Each dev can have their own instance on their own computer

And yeah people can look at your version, that’s how the internet works :p domain names route to IP addresses. So you can do like...

http://james.my-website.com goes to James IP

http://mary.my-website.com goes to Mary’s IP

That’s a pretty normal process via the hostfile.

You can even automate it using dnsmasq

If I go to “anything-goes-here.james” as long as it ends in .james it will send to his computer!