For Mac users Laravel Valet is an execellent tool to develop all your PHP projects locally.
Published by Mark van Eijk on April 26, 2023 · 2 minute read
- What is Laravel Valet?
- Not only for Laravel apps
- How to install Laravel Valet
- How does it work
- Using different PHP versions
What is Laravel Valet?
Laravel Valet is a tool that makes developing locally more enjoyable, because it makes your Mac instantly ready for development on your local computer. It's a minimalist tool, that uses Homebrew to install everything you need and get started quickly.
Laravel Valet uses Nginx, DnsMasq and PHP binaries to make it easy to develop using PHP and being able to switch to different PHP versions.
Not only for Laravel apps
Despite its name, Laravel Valet is not only for developing Laravel apps. Valet supports out of the box the following types of projects to run locally on your computer.
- CakePHP 3
- Static HTML
How to install Laravel Valet
First ensure Homebrew is up to date with the latest software packages:
Then, install PHP using:
brew install php
Make sure that
~/.composer/vendor/bin is in your system's PATH, so that after composer is installed, you can install Laravel Valet as a global package:
composer global require laravel/valet
At last, install Valet using the
After that, you can use any *.test domain to use locally on your projects.
How does it work
Laravel Valet uses a simple paradigm: every domain is a folder inside "parked" directory. So when you want to use the Mac folder
~/Sites to clone all your projects on your computer in, you can
park inside this directory to make all folders available as a
cd ~/Sites valet park
Using different PHP versions
Install different PHP versions you need for you local repositories, you can install additional PHP version using:
brew install email@example.com
Replace the version number with the version you want to install. After that you can tell Laravel Valet to use this PHP version for your project or as a new default PHP version for all sites.
To use PHP 8.3 for all sites:
valet use firstname.lastname@example.org # use --force when this is not enough
Or only for a specific site:
valet isolate email@example.com # execute this inside the correct ~/Sites/[site] folder
You can also set a specific version for Laravel Valet to use, when using the
valet use (without a PHP version) command. The PHP version can be determined from a
.valetrc file in the root of the project:
After adding this file, you can execute
valet use to always use the specified PHP version with Laravel Valet.
Subscribe to our newsletter
Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!