In summary, work with Bedrock, use a git repository and use simple SQL batch to export/import your database between your different environments.
I work with WordPress since three years now and I tried a lot of stuff to do that with some plugins, some scripts, etc. I discovered last year a great boilerplate for WP called Bedrock. It changes the files structure to something more git-friendly and I now use it for all my WP projects. It comes with some great (or rather indispensable) options like brypt for passwords, composer and environment variables.
So basically, I personally use MAMP (but XAMPP is fine too) and use a directory that contains all my repositories. I just changed the Document Root
each time I switch project. With Bedrock the only steps you need to do are
- Download SQL batch of your production (you can create a batch script to automatise that if you want
- Download your
upload
folder (contains all the medias and content submitted directly by the website) - Update your .env with correct URL + SQL logins
- Change your
Document Root
on your local web server (MAMP or XAMPP)
You can use CI/CD to sync your production with your git repository automatically. In my agency we’re using Buddy because it’s very simple & fast to configure.
If you want another solution, I also tried Local WP to work locally but I still prefer the manual way as I mainly work on little projects with a little team.