Laravel Valet
Introduction
Valet is a Laravel development environment for Mac minimalists. No Vagrant, no /etc/hosts
file. You can even share your sites publicly using local tunnels. Yeah, we like it too.
Laravel Valet configures your Mac to always run Nginx in the background when your machine starts. Then, using DnsMasq, Valet proxies all requests on the *.test
domain to point to sites installed on your local machine.
In other words, a blazing fast Laravel development environment that uses roughly 7 MB of RAM. Valet isn't a complete replacement for Vagrant or Homestead, but provides a great alternative if you want flexible basics, prefer extreme speed, or are working on a machine with a limited amount of RAM.
Out of the box, Valet support includes, but is not limited to:
- Laravel
- Lumen
- Bedrock
- CakePHP 3
- Concrete5
- Contao
- Craft
- Drupal
- Jigsaw
- Joomla
- Katana
- Kirby
- Magento
- OctoberCMS
- Sculpin
- Slim
- Statamic
- Static HTML
- Symfony
- WordPress
- Zend
However, you may extend Valet with your own custom drivers.
Valet Or Homestead
As you may know, Laravel offers Homestead, another local Laravel development environment. Homestead and Valet differ in regards to their intended audience and their approach to local development. Homestead offers an entire Ubuntu virtual machine with automated Nginx configuration. Homestead is a wonderful choice if you want a fully virtualized Linux development environment or are on Windows / Linux.
Valet only supports Mac, and requires you to install PHP and a database server directly onto your local machine. This is easily achieved by using Homebrew with commands like brew install php
and brew install mysql
. Valet provides a blazing fast local development environment with minimal resource consumption, so it's great for developers who only require PHP / MySQL and do not need a fully virtualized development environment.
Both Valet and Homestead are great choices for configuring your Laravel development environment. Which one you choose will depend on your personal taste and your team's needs.
Installation
Valet requires macOS and Homebrew. Before installation, you should make sure that no other programs such as Apache or Nginx are binding to your local machine's port 80.
- Install or update Homebrew to the latest version using
brew update
. - Install PHP 7.3 using Homebrew via
brew install php
. - Install Composer.
- Install Valet with Composer via
composer global require laravel/valet
. Make sure the~/.composer/vendor/bin
directory is in your system's "PATH". - Run the
valet install
command. This will configure and install Valet and DnsMasq, and register Valet's daemon to launch when your system starts.
Once Valet is installed, try pinging any *.test
domain on your terminal using a command such as ping foobar.test
. If Valet is installed correctly you should see this domain responding on 127.0.0.1
.
Valet will automatically start its daemon each time your machine boots. There is no need to run valet start
or valet install
ever again once the initial Valet installation is complete.