Back in 2016, I wrote a blog post about using Laravel Homestead as my local environment. At the time, my only real options were Vagrant or MAMP as an Apple user. Since then, the number of options has increased slightly to include Local by Flywheel, a more significant push to using your computer, and a set of packages like nginx and dsnmasq to run a local environment from a directory on the fly.
At the time, Homestead was my local development environment of choice because it was easy to install, quickly configurable, and lightweight—something I appreciated using an older MacBook Air as my daily driver at the time. However, the more robust my sites became, and the more websites I collected on my local, the slower Homestead appeared to run almost certainly because it relies on VirtualBox or a virtual system to run your instance, which caused me to look elsewhere. I avoided MAMP or Vagrant and similar software because they were too resource heavy for my late 2011 setup for many of the same reasons.
Flywheel offers a solution (at the time called Pressmatic; Flywheel acquired the company in late 2016), which provides individually configurable docker instances in which to run a WordPress website. It handles all of the MySQL and PHP configurations, allows for additional setup configs and all of the DNS handlings. Although it does still utilize VirtualBox, it feels and runs far lighter in weight than any of the other options as far as I’m concerned.
Local is free and allows you to quickly spin up a new Docker instance which provides you with a step-by-step interface in which to help you configure your new WordPress website.
The idea here is that each new site has its separate install, so there’s no shared PHP, MySQL, etc., versions/settings. You’re allowed a bit more flexibility. This is especially helpful when you are maybe working on older websites or websites that are using a version of something that is perhaps not the industry standard. It’s also useful when/if you need to move the site from your local to a production environment. Since everything is self-contained, you don’t run the risk of having versioning conflicts.
It does make sure that all of the developers are on the same page and can be set up quickly. You can export an entire website, database and all, that can be swiftly installed on another computer. It just takes a little time for Local to do its thing.
It does fall short in a few areas though. Local is specially built to handle a WordPress install, and although I don’t run into too many issues trying to run some other PHP or node app out of the local instance, you still have to deal with cleaning out the
public directory and tweaking a few things or installing additional dependencies. So, it’s not a great all-around local development environment.
Another thing that bothers me a little bit about Local, although it’s not necessarily a deal breaker, is that it’s quite obviously marketed to work directly with Flywheel hosting services. They make it easy with a sync feature to develop locally and push to their environment. The reason that this is problematic for me is that these are features I don’t need since I don’t currently use Flywheel hosting services. But it also means that configurations and setup are tailored explicitly for Flywheel and may, though this is anecdotal, have some additional site configurations or structure that are maybe not 100% needed or compatible with another server environment.
There are a bunch of other options out there to do something very similar. Some are newer than others, but as far as I can tell, Local is probably the newest app out there to handle this.
- XAMPP Installers and Downloads for Apache Friends
- Scotch Box
- MAMP & MAMP PRO
- Manual Setup
I’m sure there are many other apps or configurations out there, but these were the most available when searching online.
Local is good-looking, reasonably lightweight, and easy to set up. But it wasn’t the best option for me. Even now having a more powerful MacBook Pro, I just needed more flexibility. I no longer work strictly in the WordPress space; so, branching out into Node, React, and Vue.js applications, which as often as I spin up test sites, just wasn’t worth the extra configurations that are needed with Local by Flywheel.
Enter Valet, another option by Laravel. I’ll run through how quick the setup is in a moment, but I wanted to run through the features of Valet that, to me, made it the best option for my local development.
Ease of setup aside, the main thing that made Valet the best option for me was the way that it allows you to set up, create, and extend local websites.
- Valet allows you to either use a single random folder anywhere on your computer by using the
valet linkcommand, which is awesome if you need to spin something up quick and destroy it just as fast. It also allows you to serve up any folder inside a directory as a separate website using
- In this instance, I have a single directory
Serverwhich contains eight subfolders. Each of those folders is it’s own local instance, for example,
- Valet provides some quick and easy configuration options all done through the command line. You can set up an SSL on the fly with
- Finally, Valet has built-in sharing (for unsecured sites only at the moment) using ngrok and the
valet sharecommand, providing a secure publicly accessible URL hosted directly on your local machine.
That’s it for features. It’s super simple and relies on the versions of PHP or MySQL that your computer already relies on, so no guesswork or configurations there. You can follow the docs up on their website for setup but let’s run through this in five minutes or less.
- Install Homebrew and update.
- Install PHP version 7.2 with
brew install [email protected]
- Require Valet using Composer with
composer global require laravel/valet(this step may require additional setup here)
- Install Valet with
That’s it! Super easy.
Valet opens itself up to custom drivers to extend functionality, and there are a bunch of different options out there to make your workflow even smoother. Here are just a couple:
- Easily spin up a new WordPress website: wp-cli-valet-command.
- Support for Multisite installs: WordPressMultisiteSubdirectoryValetDriver
Valet out-of-the-box has a few downsides, specifically that you cannot quickly change PHP versions or create databases or import them. You can, of course, update your system PHP manually with Homebrew, but I don’t always trust myself to make any manual update to dependencies. This is, of course, why I’m hesitant to set up any local environment manually and went for Valet.
- Easily turn on XDebug with
valet xdebug on/off.
- Change PHP versions quickly with
valet use 5.6or
valet use 7.1etc.
- Quickly spin up, drop or export a database with
valet db create <name>,
valet db drop <name>, or
valet db export <filename> <name>.
Where I’m at Now
As of now, my local environment is firmly set with Valet+ using the wp-cli-valet-command package; I can quickly spin up a new WordPress site in less than a minute. And just creating a new directory in my `Server` file gives me a new space to spin up a new create-react-app in seconds. I can’t say that’s true of any other local development environment currently.
So what are you using? Do you use Valet or Valet+? Have you found a more lightweight and quick-to-use option out there I didn’t mention? Tell us in the comments below.