Yesterday, Taylor Otwell released Laravel Valet.
If you’re just interested in the broad strokes of what it is, who it’s for, and how it works, watch the funny (and slightly NSFW) video below. If you’d like to go more in depth and find out some more details about the product, and learn why it caused such a polarizing fuss on Reddit and Twitter, read on after the jump.
Valet is a tool which makes spinning up demo or discardable projects a breeze.
It’s a tool which combines some of the default software on OS X with some ideas about filepaths and serving of PHP apps, and some additional tools for skipping the need to modify the
/etc/hosts file. Additionally, it allows for forwarding of access to the local application over the public internet when needed.
Unlike Vagrant or Docker It offers no isolation, making all apps use the same globally available software. Why this is important to note will be explained below.
Let’s dive into the particulars, one by one.
OS X only
Valet is currently OS X only. This is currently the number one complaint from newcomers running into Valet.
While, technically, it should be possible to make it work on Linux given the amount of architecture the two systems share and the fact that most Linux distros have an old version of PHP pre-installed, Windows will likely never become an option without a full, OS-specific rewrite.
It’s not a conspiracy. Taylor does not belong to the cult of Apple, and he isn’t trying to be elitist. It’s just very easy to develop projects like these for OS X because of a very good package manager (Homebrew) and sensible defaults already being pre-installed.
Shared system state
Due to not using VMs or containers, Valet relies on the version of PHP installed on OS X. Not many people know this but OS X in fact ships with PHP pre-installed, though an admittedly outdated version (at the time of writing it defaults to 5.5.31). While that version is enough for running the most rudimentary applications, it’d be a shame not to use the most recent version.
To update to PHP7 on OS X using Homebrew, first install Homebrew and then run:
brew update brew tap homebrew/dupes brew tap homebrew/versions brew tap homebrew/homebrew-php brew install php70 brew cleanup
Finally, make OS X execute the new PHP by default by adding the following line to your
Then, either relaunch your terminal windows or run
source ~/.bash_profile for the change to take effect.
Note that you also need to have Composer installed globally for Valet to work.
This is one of the major downsides of Valet, by the way, and akin to using MAMP or XAMPP and similar tools – all the apps will be using the same database / PHP version / extensions. That means the dependence on one can ruin other apps’ dependence on others. Be careful in starting serious projects with Valet!
Automatic virtual host
Valet uses DnsMasq to simulate virtual hosts in that it takes any folder name you create with it and makes the app within accessible via a
For example, if you run
valet park in a specific folder, Valet will search said folder for project setups matching the ones it supports and immediately make them accessible in the browser with the
.dev suffix. Thus, creating a new Laravel project in
~/my-sites/laravel will make the site available on
Note that for this to work, you do not need to touch
etc/hosts at all, as opposed to the situation with Vagrant.
This makes previewing the demo apps you’re building much, much simpler, and completely skips the need for Apache or Nginx configuration – a tremendous headache for most people.
.dev by default. While not in widespread use,
.dev is actually a valid top level domain. Valet can be configured to use a different suffix, however. After installing it with Composer (preferably globally) enter its home folder and find the file
config.json. There will be a
domain key there with the value
.dev. Changing this to something like
.devlocal should do the trick.
Dev / prod parity
If you’ve read my book, you might be wondering “But what about dev / prod parity?”
You’d be right to wonder – it’s quite a big deal. The environment you’re developing in this way is so far removed from any possible production environment, it’s practically ludicrous to expect anything to run the way it does during development. That’s why Valet is suitable only for:
- demo / throwaway projects
- or, people who are absolutely certain they’ve configured their prod environment to match all the conditions of the app as developed under Valet
The latter is quite the impossibility, so I doubt we’ll see many serious, long term projects developed with Valet.
Vendor-lock (with a caveat)
Right now, Valet supports only the following types of applications:
This is because it relies on a specific file and folder layout to properly host things with the built-in PHP server. However, Valet does support custom drivers which allow for extending the tool and adding new ways to host alternative application structures.
Keep this in mind when you try to run your custom application with it and find it not working!
Live self-hosted preview
One of the major selling points of Valet is the ease with which one is able to share a work in progress with a client or another developer. Running
valet share in an application’s folder will make it publicly available online via an automatically generated link. To stop sharing the site, simply stopping the service with
Ctrl + C does the trick.
Behind the scenes, Valet uses Ngrok to accomplish this.
Sure, the entire set of tools in Valet is something you can use on your own, too, but in typical Laravel fashion, many smaller, useful things have been put in one convenient package to make the entire process of developing and debugging an app much faster. After all, what is Laravel itself if not a collection of incredibly handy packages all wrapped up in one extremely practical whole?
For more information about Laravel Valet, please see the documentation. We won’t be abandoning our Homestead Improved any time soon in favor of Valet (cross-platform friendliness is more important to us), but there’s definite value in Valet – from handy tools that expedite the sharing and self-hosting process to resource usage (only about 7MB of RAM!), Valet has a plethora of advantages over setups like MAMP or XAMPP.
Will you be using it?
PHP Authorization with JWT (JSON Web Tokens)
By Miguel Ibarra Romero, Matthew Setter,
Need to authenticate requests to a server? Learn what JWTs are and how to use them instead of sessions to authenticate your users via API calls.
Setting Up a Modern PHP Development Environment with Docker
By Tom Butler,
There are so many ways to set up your PHP development environment, but using Docker is the current best practice. Let's walk through how to do it properly.
Getting Started with Laravel Livewire
By Wern Ancheta,
Bruno is a blockchain developer and technical educator at the Web3 Foundation, the foundation that's building the next generation of the free people's internet. He runs two newsletters you should subscribe to if you're interested in Web3.0: Dot Leap covers ecosystem and tech development of Web3, and NFT Review covers the evolution of the non-fungible token (digital collectibles) ecosystem inside this emerging new web. His current passion project is RMRK.app, the most advanced NFT system in the world, which allows NFTs to own other NFTs, NFTs to react to emotion, NFTs to be governed democratically, and NFTs to be multiple things at once.