Proper PHP development environment on Windows

Sreten Madžgalj
sreten_madzgalj
May 13, 2015

Developing PHP applications on a Windows machine can sometimes turn into a developer nightmare. 

Installing LAMP stacks or setting up Apache, PHP and MySQL one by one can be a tedious process.
You run into weird problems with missing modules, different configuration compared to standard servers, and sometimes you can’t pull changes from a repository only because a file name has more characters than Microsoft finds appropriate.

Oh, and remember that you have to change Skype options so it doesn’t block port 80.
Lucky for us, there is a simple solution – develop on – Linux.

But I don’t want to change my OS

Of course you don’t. Windows is a great operating system with amazing applications and a huge user base and you shouldn’t change it due to some minor inconvenience. 
Instead, install a Linux virtual machine.

Virtual Machines in action

VM technology is nothing new. It is used for a long time in software development for testing and simulating different environments.
But it’s also a perfect way to create a powerful Linux server for PHP development without installing Linux itself.

Introducing Vagrant

However, installing and setting up a virtual machine is even more tedious than setting up a LAMP stack.
Wouldn’t it be great if you could just pick what Linux distribution you want and what packages you want installed and have an app do the heavy-lifting?
That’s exactly whereVagrant jumps in.

You basically create a special file called Vagrantfile, chose what box you want installed and run vagrant up from console. 

Boxes in Vagrant are actually packaged virtual machines. You can find open source boxes on VagrantCloud, or you can create your own.

Virtual machine providers

Before using Vagrant, you need a virtual machine provider. That’s because Vagrant doesn’t provide virtualization software, instead it exposes a way of managing virtual machines with console commands and Vagrantfiles.

Some popular VM providers are:

  • VirtualBox
  • VMware
  • Hyper-V

Most developers choose VirtualBox because it’s free and open source.

Advantages of this set up

Virtual machine providers allow you to set a shared folder. It’s a special folder on your Windows machine mounted directly on VM. Any change you make to files in that folder is automatically synced to VM/Windows. (Technology behind this is Linux mount – read more).

This means you can have your DocumentRoot and all files inside it accessible from your Windows machine, while they are running in VM. You can use your Windows IDE without auto-uploading and syncing with the server.

Another big advantage of this setup is that your Windows machine remains uncluttered by executables, scripts and plugins like nodejs, composer, ruby etc. Everything is sandboxed in another OS that can be copied, deleted or moved easily.

More about Vagrant

Official website with documentation:
https://www.vagrantup.com/ 

In-depth tutorial with installation instructions:
https://www.devmynd.com/blog/2014-2-why-aren-t-you-using-vagrant

Laravel framework ima svoj box, konfigurisan za razvoj PHP i Laravel aplikacija:
http://laravel.com/docs/master/homestead

Share
some love

They trust us, so should you!

Be one of them