Step-by-step instructions for installing XAMPP, configuring paths, and installing Composer on macOS:
- Go to XAMPP download page and download the DMG file.
- Open the downloaded DMG file.
- Press F4 and search for "Privacy and Security."
- In the "Security" section, you'll find the blocked app. Click "Open Anyway" to continue with the installation.
- Start the XAMPP services.
- Open the terminal.
- Look in the title for either "bash" or "zsh."
For Zsh:
cat ~/.zshrcFor Bash:
cat ~/.bash_profile- Open the appropriate profile file (either
~/.zshrcor~/.bash_profile) based on your shell type.
For Zsh:
nano ~/.zshrcFor Bash:
nano ~/.bash_profile- Add the following lines to set XAMPP paths:
export XAMPP_HOME=/Applications/XAMPP
export PATH=${XAMPP_HOME}/bin:${PATH}
export PATH-
Save the changes.
-
Load the changes:
source ~/.zshrc # For Zsh
source ~/.bash_profile # For Bash- Confirm the changes:
which php # Should display /Applications/XAMPP/bin/php-
Go to Composer download page.
-
Download Composer:
curl -sS https://getcomposer.org/installer | php- Move Composer to
/usr/local/bin/:
sudo mkdir -p /usr/local/bin/
sudo mv composer.phar /usr/local/bin/composer- Confirm Composer installation:
composer --versionNow, XAMPP is installed and configured with the correct paths, and Composer is successfully installed and available system-wide.
but sometime we can easy to export PATH="/Applications/XAMPP/bin:$PATH" If you are using XAMPP on macOS and encountering the “php: command not found” error, you can try the following steps to resolve the issue:
Open a terminal on your macOS. Locate the XAMPP installation directory. By default, it is installed in the “/Applications/XAMPP” directory. If you have installed it in a different location, adjust the path accordingly. Add the PHP binary path to your system’s PATH environment variable. Run the following command in the terminal: