Laravel Valet was primarily designed for local Laravel development – sounds obvious right? 🙂
Valet uses the built-in PHP server from Mac (yes Valet is limited to Mac-Users, but there are forks for Linux and Windows – but we did not test those yet) and utilizes DnsMasq to proxy all requests to the
.test TLD to sites on your local machine. Valet also requires PHP and a database server installed locally on your machine.
Out of the box, Valet already supports numerous frameworks like Laravel, Lumen, Bedrock, Drupal, Symfony, WordPress and others. Additionally you can build custom drivers to support your own setup.
It’s a very simple and fast setup.
WordPress & Valet
We are using a slightly modified Bedrock setup for our WordPress projects, but you can also use the default one. The local setup is pretty easy and can be done as follows.
1. Install valet with composer
composer global require laravel/valet
2. Configure Valet
valet install for installing and configuring valet and dnsmasq. After the installation try pinging any
*.test domain and you should see that
127.0.0.1 will respond.
Auto mapping projects
Valet has a super comfortable function, which maps local sites automatically to the configured TLD domain. For enabling it switch to the designated folder and run
▲ cd ~/projects/valet
▲ valet park
All folders inside the used path will be mapped automatically. The folder name is also the site name.
3. Setup WordPress project
As usual 🙂
And that’s actually it.
You can also share local sites to others with the
valet share command. It enables sharing with a tool called ngrok.
▲ cd ~/projects/valet/towa-boilerplate
▲ valet share
After running the command inside the project folder, following screen appears:
Further useful commands
valet link: add projects outside the parked folder
valet secure: secure a local site with ssl
valet list: list all commands
Valet vs VMs
You should be aware that Valet is not a replacement for a virtual machine. If you need more advanced and extended setup you probably have to use one. Reasons for that would be for example if you need a flexible local environment without beeing tied to your local settings or if you wish to make a more production-like environment. Additionally some VMs provide other services and software you may need like Redis, Memcached, Node, Mailhog, Elasticsearch and so on.
Valet is a super simple and fast setup for a local development environment. It’s suitable for WordPress and also a couple of other frameworks who have the same requirement stack.