I use vagrant, git and some build script on phing. The vagrant machine run database and web server, git used locally to track changes in my extensions and build script used to update /var/www
directory on my vagrant machine (well actually it used everywhere where i need to build an environment).
Phing
Probably most interesting part is phing, which work like modman + composer for me. It has few targets defined including build, setup and install.
The build target download certain version of magento (specified in build config) from internal webserver and extract it into build directory. Then run other targets which setup permissions for files and cleanup the cache. Then it create symlinks to all files in the source directory. In result I get all files ready to use in my build directory. If magento core files already in build directory it skip downloading and just update symlinks, so I use this target to rebuild environment everytime I need to update symlinks. For vagrant machine source directory is in /vagrant/src
(shared folder) and build directory is /var/www
.
The install target download and import database dump for certain magento version. Then run setup target.
The setup target just create a local.xml file with all settings.
In my company we use unit testing and CI tools, so this way to build a magento environment allow us to test our extensions on different versions of magento, and run it with and without installing.
I have created a "shortcut" on vagrant machine which simplify access to build. For example to rebuild project I need just type vagrant ssh -c magebuild
and it's automatically run phing in /vagrant
directory.
Then I have assigned this command to certain key combination in my PHPStorm IDE and now I can rebuild project just by pressing Alt + B in my IDE. But since I use symlinks it's not really often operation.
Vagrant
A box for vagrant it's my own box with Ubuntu 12.04 on board, it's actually just standard precise 12.04 with all software preinstalled + shortcut and some configuration. In vagrant file I put just port forwarding settings, private network to be able to use xDebug and put build shortcut to provisions.
GIT
In git I track only my extension files, build.xml
for phing and Vagrantfile
. So everybody who want to create an environment can just clone repository, and run vagrant up. Then he will get VM up and running ready to work. All this process takes 1-2 minutes. If you want to build project locally (without using VM) you can run phing build install
.
Your question is quite broad, so hard to give an exact answer without me spending ages on a reply - but using anything like XAMPP is a bad idea from the start (I know from experience) especially with Magento.
My preferred way is to use a virtual machine running Linux - in my case Ubuntu 16.04LTS server edition (as it's the same as my production server)
Virtualbox is free - https://www.virtualbox.org/wiki/Downloads
On this virtualbox, I install nginx, php7.0-fpm etc. (as per the Magento 2 devdocs) and configure in the same manner as my production/staging servers. I'd then make a host entry in Windows that points my 'dev domain' to the virtualbox IP.
I then use n98-magerun to export a 'developer' version of my production database, a must to avoid customer data being present on your local machine (GDPR, best practices)
Mount a folder from your virtualbox into windows, you can then open this folder in an editor such as atom to work on your project.
If you work this way, then you'll have no issues when you move to Mac also, as you can work on Mac, Linux or Windows. Your virtual machine image can always be the same, and as your production and staging servers with no nasty surprises when deploying. I recommend git for deployment and general version control also.
Larger companies also use things like docker, this lets you spin up a magento instance in its own container from an image - more portable than virtualbox, but virtualbox will fit your need just fine in my opinion.
Summary
- Use same OS as your production/staging servers.
- Use same PHP versions as production/staging.
- Ensure to cleanse data from production db
- Avoid one click install solutions, you'll learn way more about Magento by doing your own deployments.
If you have any questions, let me know and I will try to elaborate in my answer :)
Best Answer
For Windows: Uniform Server is an easy-to-use portable server (WAMP stack) that supports Magento 2 out-of-box. Current configuration includes MySQL 5.6 and PHP 7.0, although you can change to other versions via module installers if you'd prefer.
Note that Magento 2.0 still has trouble running on Windows natively in development mode, due to symlink issues. See https://magento.stackexchange.com/a/64808/1905 for a fix.
That being said, Vagrant is generally the recommended approach.
For Mac or Linux, you might be better off installing the AMP packages directly rather than trying to deal with MAMP, but Vagrant would probably be easier overall.