Skip to content

Instantly share code, notes, and snippets.

@Udara-Dananjaya
Last active June 27, 2024 17:18
Show Gist options
  • Save Udara-Dananjaya/9706190fb1d72030614affdea6c372d4 to your computer and use it in GitHub Desktop.
Save Udara-Dananjaya/9706190fb1d72030614affdea6c372d4 to your computer and use it in GitHub Desktop.
macOS XAMPP Installation and Composer Setup Guide

Step-by-step instructions for installing XAMPP, configuring paths, and installing Composer on macOS:

Install XAMPP:

  1. Go to XAMPP download page and download the DMG file.
  2. Open the downloaded DMG file.
  3. Press F4 and search for "Privacy and Security."
  4. In the "Security" section, you'll find the blocked app. Click "Open Anyway" to continue with the installation.
  5. Start the XAMPP services.

Configure Paths:

Identify Shell Type:

  1. Open the terminal.
  2. Look in the title for either "bash" or "zsh."

Check if Shell Profile File Exists:

For Zsh:

cat ~/.zshrc

For Bash:

cat ~/.bash_profile

Set Paths:

  1. Open the appropriate profile file (either ~/.zshrc or ~/.bash_profile) based on your shell type.

For Zsh:

nano ~/.zshrc

For Bash:

nano ~/.bash_profile
  1. Add the following lines to set XAMPP paths:
export XAMPP_HOME=/Applications/XAMPP
export PATH=${XAMPP_HOME}/bin:${PATH}
export PATH
  1. Save the changes.

  2. Load the changes:

source ~/.zshrc   # For Zsh
source ~/.bash_profile   # For Bash
  1. Confirm the changes:
which php   # Should display /Applications/XAMPP/bin/php

Install Composer:

  1. Go to Composer download page.

  2. Download Composer:

curl -sS https://getcomposer.org/installer | php
  1. Move Composer to /usr/local/bin/:
sudo mkdir -p /usr/local/bin/
sudo mv composer.phar /usr/local/bin/composer
  1. Confirm Composer installation:
composer --version

Now, 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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment