Why development environment is so important? Why should every PHP developer must use Laravel Homestead?

Shamsul Alam Jewel
5 min readAug 3, 2019

--

Recommended development environment for PHP developers

Are you a PHP developer? Did you develop any PHP application or website before? Then you already know how important it is to setup your development environment right? Every developer’s first ever job is to setup their development environment, every one has their own preferences and experiences and that is how they set it up. So more or less it is different for each developer. It is fine and there is noting to say about it, you are the developer and you should setup your environment as you like right? Yes it’s true, but I have a problem with that, why? Let’s now think about a team that is working with the same project. Someone created the project and pushed to git repository, now other developers pull it from the repository and try to run it. It might be a fail for some developers as the development environment is not the same for all developers. We can fix this by fixing a requirement specification for this project, so every developer should have to have minimum version of PHP, MySQL, Apache etc setup. Well that might fix this project, but what will happen to the other projects!! Some developers might have involved in multiple project development, those might have some other requirements? What should they do now?

I know you might also have had the same experience as me, facing difficulties and managing this local environment for same project or for multiple projects.

The problem I faced a lot back in time is, I developed a website or a project one year ago with let’s say PHP version 5.6 and obviously released the site, handed it over to the client and never touched it again. Later, I was working with a project and it was PHP 7.1, you always want to be up to date with the latest technology right?. So if the client now comes back to me and ask to update something for that project or want to add some new features! To work with that project now I have to make my environment fit for that project and might face some issues to do that. And by this process I also can not work simultaneously with my currently working projects.

I remember that I was using Homebrew in my Macbook Pro development machine to manage multiple version of the the PHP, switching back and forth of the versions, that was manageable but it was so frustrating when each time I had to do that. So if you are still following me up to this, that means you also know how important it is to have a development environment that is very flexible and easy to manage. As a developer we all want to focus on the development, and not managing and adjusting our development environment. A good development environment makes a better developer as it increases efficiency, accuracy and makes the use of the tools much faster.

I chose Laravel (5.8) for my application development, as Laravel Homestead gives us an environment that is exactly what a developer needs. If you didn’t still hear about Laravel Homestead, I would really recommend you to check it out. It is maybe fine tuned for Laravel framework but I used this environment for all of my PHP projects, If you are a PHP developer, you will get all the benefits from it. I would highly recommend it to setup for your development environment.

Laravel Homestead is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine. Vagrant provides a simple, elegant way to manage and provision Virtual Machines.

Homestead runs on any Windows, Mac, or Linux system, and includes Nginx, PHP, MySQL, PostgreSQL, Redis, Memcached. Please checkout the link and you will see what softwares are included, how to install and setup, how to use it, all the good stuff. Here on this writing, I will show you how I manage to handle and develop multiple PHP projects on my environments!

I have created a folder name code into my profile directory, where I have put all my project directories.

Here is my Homestead.yaml file folders: map

folders:
— map: ~/code
to: /home/vagrant/code

So my ~/code is mapped to /home/vagrant/code on the virtual machine

Here is an example of my sites setting on Homestead.yaml

- map: test-website-1.dev
to: /home/vagrant/code/test1/public
php: “7.2”
- map: test-website-2.dev
to: /home/vagrant/code/test2/public
php: “7.0”

Here you can see I am using two different versions of PHP on my two different projects. Once I run test-website-1.dev site, it will run one PHP 7.2 and if I run test-website-2.dev it will run on PHP 7.0, how cool it that :)

Last thing is the site configuration of my /etc/hosts file, here it is-

192.168.10.10 test-website-1.dev192.168.10.10 test-website-2.dev

So by using Laravel Homestead, even if we work in a team on a project - still all of the developers have the same environment like server versions, PHP and MySQL versions, Apache versions etc. Developers now have easy manageable local environment that can handle all the projects they are working on.

Give it a try and I am sure you will thank me later. Good luck and happy setup.

Yes, you can do it!

--

--