Laravel Herd

Documentation for macOS

Manage PHP versions

#
Using different PHP versions

Herd ships with the latest stable PHP version by default. Currently, that's PHP 8.3. However, you may install and use different PHP versions for your projects.

#
Via the GUI

You can manage your PHP versions in the "PHP" tab of the preferences window. Here you can choose which PHP versions you want to install or update.

In order to change the global PHP version that is used by Herd, select it in the dropdown menu in the menu bar.

The selected PHP version will be used for all sites that are not isolated.

#
Via the CLI

If you prefer to use the CLI, you can use the herd use command to switch between PHP versions.

herd use 8.2

#
Per-site PHP versions

By default, Herd will use the global PHP version to serve all your sites. However, if you need to support different PHP versions for different sites, you may use the isolated sites functionality. This configures Herd to use the specified PHP version for the site, regardless of the global PHP version.

#
Via the GUI

You can configure the PHP version to use per site in the "Sites" tab of the preferences window. This gives you a list of all your sites and allows you to configure the PHP version to use for each site.

Just select the PHP version you want to use for the site in the dropdown menu.

#
Via the CLI

If you prefer to use the CLI, you can use the herd isolate command to specify which PHP version a particular site should use. The isolate command configures Herd to use the specified PHP version for the site located in your current working directory:

cd ~/Herd/example-site
 
herd isolate 8.0

If your site name does not match the name of the directory that contains it, you may specify the name using the --site option:

herd isolate 8.0 --site="site-name"

For convenience, you may use the herd php, composer, and which-php commands to proxy calls to the appropriate PHP CLI or tool based on the site's configured PHP version:

herd php
herd composer
herd which-php

You may execute the isolated command to display a list of all of your isolated sites and their PHP and Node.js versions:

herd isolated

To revert a site back to Herd's globally installed PHP version, you may invoke the unisolate command from the site's root directory:

herd unisolate