allejo / mampenv

mampenv is PHP shims for MAMP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mampenv - PHP CLI multi-version management for MAMP

I've historically had trouble with getting phpenv to successfully build certain versions of PHP on my Mac, so I started using the versions that were distributed by MAMP. mampenv is here to help you switch between MAMP's PHP versions just like phpenv and rbenv. Put a .php-version file in the root of your project folder and have the peace of mind of knowing that your PHP CLI version will remain consistent.

Key features:

  • Run MAMP-supported PHP versions directly from the command line
  • Run composer using the correct PHP version
  • Use project-specific versions of MAMP's PHP installations
  • PEAR? PECL? Oh yes, each MAMP version of PHP already has that

How It Works

mampenv operates on the per-user directory ~/.mampenv. This directory contains shim-style scripts that take over the php and composer commands on the command line. It will make sure they are executed using the PHP version in the following order:

  1. Specified in your project folder's .php-version file, if one is present
  2. Specified in ~/.mampenv/version
  3. The system default PHP version, if one is present

Each MAMP PHP version is a stand-alone installation with its own binaries and configuration.

Installation

This will get you going with the latest version of mampenv and make it easy to fork and contribute any changes back upstream.

  1. Check out mampenv into ~/.mampenv.

    cd
    git clone https://github.com/allejo/mampenv.git ~/.mampenv
  2. Add ~/.mampenv/bin to your $PATH for access to the mampenv command-line utility. In your shell's profile file (e.g. ~/.bash_profile or ~/.zshrc), add the following line:

    export PATH="$HOME/.mampenv/bin:$PATH"
  3. Restart your shell so the path changes take effect or source your profile file.

    source ~/.zshrc
  4. If all goes well, which php should indicate a ~/.mampenv/bin/php path. which composer should say ~/.mampenv/bin/composer and which pecl should say ~/.mampenv/bin/pecl.

Upgrading

If you've installed mampenv using the instructions above, you can upgrade your installation at any time using git. To upgrade to the latest development version of mampenv, use git pull:

cd ~/.mampenv
git pull

Usage

Like git, the mampenv command delegates to subcommands based on its first argument. The most common subcommands are:

versions

List the local MAMP PHP versions installed.

mampenv versions

local [version]

Create a new .php-version file in the current directory.

# Display the version configured in a `.php-version`
mampenv local

# Set the version to use in the current directory
mampenv local 7.1.0

global [version]

Create or display the global PHP value in ~/.mampenv/version.

# Display the global version
mampenv global

# Set the global version to use
mampenv global 7.1.0

License

MIT License

About

mampenv is PHP shims for MAMP

License:MIT License


Languages

Language:Shell 100.0%