Knowledge

Laravel Valet

#Laravel

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

  1. What is Laravel Valet?
  2. Not only for Laravel apps
  3. How to install Laravel Valet
  4. How does it work
  5. 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.

  • Laravel
  • Bedrock
  • CakePHP 3
  • ConcreteCMS
  • Contao
  • Craft
  • Drupal
  • ExpressionEngine
  • Jigsaw
  • Joomla
  • Katana
  • Kirby
  • Magento
  • OctoberCMS
  • Sculpin
  • Slim
  • Statamic
  • Static HTML
  • Symfony
  • WordPress
  • Zend

How to install Laravel Valet

First ensure Homebrew is up to date with the latest software packages:

brew update

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 install command:

valet install

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 [folder].test domain.

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 php@8.3

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 php@8.3 # use --force when this is not enough

Or only for a specific site:

valet isolate php@8.3 # 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:

php=php@8.3

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!

Related articles

How to use different PHP versions with Laravel Valet

For Mac users Laravel Valet is an execellent tool to develop all your PHP projects locally.

Read more →

Disable cookies in Laravel

For Mac users Laravel Valet is an execellent tool to develop all your PHP projects locally.

Read more →