Shell Setup
Check Your Shell
Section titled “Check Your Shell”macOS uses zsh by default (since Catalina). Check your shell:
echo $SHELL# orecho $0Which File to Edit
Section titled “Which File to Edit”| Shell | Config file |
|---|---|
| zsh (macOS default) | ~/.zshrc |
| bash | ~/.bashrc or ~/.bash_profile |
What to Add
Section titled “What to Add”Add the following line at the end of the appropriate file:
export PATH="/opt/php/bin:$PATH"Reload Configuration
Section titled “Reload Configuration”After saving the file, reload your shell configuration:
# For bashsource ~/.bashrc
# For zshsource ~/.zshrcInstall PHP
Section titled “Install PHP”Now you can install PHP:
# Update the package indexphm update
# Install PHP 8.5 with FPM and popular extensionsphm install php8.5-cli php8.5-fpm php8.5-redis php8.5-opcache
# Set as default versionphm use 8.5Verification
Section titled “Verification”Check that everything is set up correctly:
which phpphp -v# Should show: PHP 8.5.x