php

Install

Use Homebrew to install and manage PHP versions in your local environment.

Usage

which php

# /usr/local/bin/php
php -v

# PHP 8.4.2 (cli) (built: Dec 17 2024 15:31:31) (NTS)
# Copyright (c) The PHP Group
# Zend Engine v4.4.2, Copyright (c) Zend Technologies
#     with Zend OPcache v8.4.2, Copyright (c), by Zend Technologies

Switch PHP version

Local PHP versions are managed with Homebrew, but docs for doing that are maintained here.

First, install the desired PHP version:

brew install [email protected]

Second, tell Valet to use that version:

valet use [email protected]
valet restart