Skip to content

Instantly share code, notes, and snippets.

@Swiss-Mac-User
Created April 15, 2022 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Swiss-Mac-User/2f3e5c3e9b321705e17b3986a989e7bb to your computer and use it in GitHub Desktop.
Save Swiss-Mac-User/2f3e5c3e9b321705e17b3986a989e7bb to your computer and use it in GitHub Desktop.
MAMP Apache, PHP and Composer configurations on macOS
# === MAMP App ===
# Start/Stop
alias mamp='/Applications/MAMP/bin/start.sh'
alias mamp_stop='/Applications/MAMP/bin/stop.sh'
# === MAMP Apache ===
alias apachectl='/Applications/MAMP/Library/bin/apachectl'
alias apache='apachectl'
# Server Variables
export ENVIRONMENT='development'
readonly ENVIRONMENT
# === MAMP PHP ===
#PHP_VERSION5='5.6.40'
#php5="/Applications/MAMP/bin/php/php${PHP_VERSION5}/bin/php"
#alias php5=${php5}
#export php5
#readonly php5
# PHP 7.x
PHP_VERSION7='7.4.21'
php7="/Applications/MAMP/bin/php/php${PHP_VERSION7}/bin/php"
alias php7=${php7}
export php7
readonly php7
# PHP 8.x
PHP_VERSION8='8.0.8'
php8="/Applications/MAMP/bin/php/php${PHP_VERSION8}/bin/php"
alias php8=${php8}
export php8
readonly php8
# Set the 'php' alias to the desired primary version
# Note: needed for Composer!
PHP_USE=7
# Config default php
PHP_PREFIX=php
PHP_VERSION="PHP_VERSION${PHP_USE}"
PHP_VERSION_DIR="${PHP_PREFIX}${PHP_VERSION}"
php="${PHP_PREFIX}${PHP_USE}"
alias php=${php}
export php
readonly php
# === Composer ===
# NOTE: Must come AFTER PHP aliases, because might rely on them.
# •• Sources ••
# - https://gist.github.com/kkirsche/5710272#gistcomment-1541612
# - https://tommcfarlin.com/setting-php-and-composer-in-mamp/
#
# If Composer is packed within your MAMP installation (DEPRECATED):
#alias composer="php /Applications/MAMP/bin/php/${PHP_VERSION_DIR}/bin/composer.phar"
#export PATH=/Applications/MAMP/bin/php/${PHP_VERSION_DIR}/bin:$PATH
# ...otherwise use manually installed from /user/local/bin/
# (Install via homebrew using: brew install composer )
export PATH="${php}:$PATH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment