wilmoore / php-version

stupid simple PHP version management
https://github.com/wilmoore/php-version
MIT License
679 stars 99 forks source link
homebrew-php php php-version php-versions shell-script version-manager

simple PHP version switching

php-version exposes a php-version command allowing developers to switch between versions of PHP.

This IS for you if

This is NOT for you if

Rationale

php-version attempts to stick to the classic UNIX notion that tools should do one thing well.

While there are smart alternative tools that attempt to solve this problem, none of the tools I've found were simple enough for me.

Features

Non-Features

Usage Examples

Switch to a specific PHP version

% php-version <version>

List installed and active (*) PHP version(s)

% php-version
  5.3.9
  5.3.10
  5.4.0RC8
  5.4.0RC6
  5.4.0
* 5.4.8

Install

homebrew (recommended for OSX users)

% brew tap wilmoore/formulae
% brew install php-version

cURL (for non-OSX users or those that prefer not to use homebrew):

% mkdir -p $HOME/local/php-version # or your place of choice
% cd !$
% curl -# -L https://github.com/wilmoore/php-version/tarball/master | tar -xz --strip 1

Alternative (i.e. non-Homebrew) installation methods are documented on the wiki.

Setup

Add one of the following to your shell's initialization file:

# Homebrew (recommended)
source $(brew --prefix php-version)/php-version.sh
php-version 5

# non-Homebrew
source $HOME/local/php-version/php-version.sh # or your place of choice
php-version 5

Type php-version --help for more configuration options such as how to add extra PHP installation paths or php-config --version to find out which php version is active.

If you have PHP versions in multiple directories, you can list them in the environment variable PHP_VERSIONS separated by spaces as depicted below:

export PHP_VERSIONS="$HOME/local/php $HOME/php/versions"

NOTE: do this before you source php-version.sh:

Deactivate / Uninstall

  1. Remove setup configuration.

  2. Enter one of the following commands listed below to remove associated files.

    # Homebrew (recommended)
    % brew remove --force php-version
    
    # non-Homebrew
    % rm -rf $HOME/local/php-version

Having Issues?

  1. Copy the bug report output to your clipboard (pbcopy works on Mac OSX; use your OS equivalent)

    % cd /tmp
    % git clone https://github.com/wilmoore/php-version.git
    % source php-version/bug-report.sh | pbcopy
  2. File an issue.

More Info

Contributors

https://github.com/wilmoore/php-version/graphs/contributors

Alternatives

Inspiration

LICENSE

MIT