Skip to content

Instantly share code, notes, and snippets.

@yuya-takeyama
Created October 22, 2011 12:10
Show Gist options
  • Save yuya-takeyama/1305922 to your computer and use it in GitHub Desktop.
Save yuya-takeyama/1305922 to your computer and use it in GitHub Desktop.
`install* sub-command for phpenv. *NOT* for rbenv.

phpenv install

It provides install sub-command for phpenv using php-build.

Requirements

Installation

Save rbenv-install file into $HOME/.phpenv/libexec directory.

Usage

$ phpenv install VERSION

Available versions can be checked like following.

$ php-build --definitions

Thanks

This script almost taken from Sam Stephenson's rbenv-install command in rbenv.

phpenv and php-build is CHH's works.

#!/usr/bin/env bash
set -e
[ -n "$RBENV_DEBUG" ] && set -x
# Provide rbenv completions
if [ "$1" = "--complete" ]; then
exec php-build --definitions
fi
if [ -z "$RBENV_ROOT" ]; then
RBENV_ROOT="${HOME}/.phpenv/libexec"
fi
DEFINITION="$1"
case "$DEFINITION" in
"" | -* )
{ echo "usage: phpenv install VERSION"
echo
echo "Available versions:"
php-build --definitions | sed 's/^/ /'
echo
} >&2
exit 1
;;
esac
VERSION_NAME="${DEFINITION##*/}"
PREFIX="${RBENV_ROOT}/versions/${VERSION_NAME}"
php-build "$DEFINITION" "$PREFIX"
phpenv rehash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment