Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
933 additions
and
1,007 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../libexec/phpenv |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
_phpenv() { | ||
COMPREPLY=() | ||
local word="${COMP_WORDS[COMP_CWORD]}" | ||
|
||
if [ "$COMP_CWORD" -eq 1 ]; then | ||
COMPREPLY=( $(compgen -W "$(phpenv commands)" -- "$word") ) | ||
else | ||
local words=("${COMP_WORDS[@]}") | ||
unset words[0] | ||
unset words[$COMP_CWORD] | ||
local completions=$(phpenv completions "${words[@]}") | ||
COMPREPLY=( $(compgen -W "$completions" -- "$word") ) | ||
fi | ||
} | ||
|
||
complete -F _phpenv phpenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
function __fish_phpenv_needs_command | ||
set cmd (commandline -opc) | ||
if [ (count $cmd) -eq 1 -a $cmd[1] = 'phpenv' ] | ||
return 0 | ||
end | ||
return 1 | ||
end | ||
|
||
function __fish_phpenv_using_command | ||
set cmd (commandline -opc) | ||
if [ (count $cmd) -gt 1 ] | ||
if [ $argv[1] = $cmd[2] ] | ||
return 0 | ||
end | ||
end | ||
return 1 | ||
end | ||
|
||
complete -f -c phpenv -n '__fish_phpenv_needs_command' -a '(phpenv commands)' | ||
for cmd in (phpenv commands) | ||
complete -f -c phpenv -n "__fish_phpenv_using_command $cmd" -a "(phpenv completions $cmd)" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
if [[ ! -o interactive ]]; then | ||
return | ||
fi | ||
|
||
compctl -K _phpenv phpenv | ||
|
||
_phpenv() { | ||
local words completions | ||
read -cA words | ||
|
||
if [ "${#words}" -eq 2 ]; then | ||
completions="$(phpenv commands)" | ||
else | ||
completions="$(phpenv completions ${words[2,-1]})" | ||
fi | ||
|
||
reply=("${(ps:\n:)completions}") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
export -n CDPATH | ||
|
||
if [ "$1" = "--debug" ]; then | ||
export PHPENV_DEBUG=1 | ||
shift | ||
fi | ||
|
||
if [ -n "$PHPENV_DEBUG" ]; then | ||
export PS4='+ [${BASH_SOURCE##*/}:${LINENO}] ' | ||
set -x | ||
fi | ||
|
||
resolve_link() { | ||
$(type -p greadlink readlink | head -1) "$1" | ||
} | ||
|
||
abs_dirname() { | ||
local cwd="$(pwd)" | ||
local path="$1" | ||
|
||
while [ -n "$path" ]; do | ||
cd "${path%/*}" | ||
local name="${path##*/}" | ||
path="$(resolve_link "$name" || true)" | ||
done | ||
|
||
pwd | ||
cd "$cwd" | ||
} | ||
|
||
if [ -z "${PHPENV_ROOT}" ]; then | ||
PHPENV_ROOT="${HOME}/.phpenv" | ||
else | ||
PHPENV_ROOT="${PHPENV_ROOT%/}" | ||
fi | ||
export PHPENV_ROOT | ||
|
||
if [ -z "${PHPENV_DIR}" ]; then | ||
PHPENV_DIR="$(pwd)" | ||
else | ||
cd "$PHPENV_DIR" 2>/dev/null || { | ||
echo "phpenv: cannot change working directory to \`$PHPENV_DIR'" | ||
exit 1 | ||
} >&2 | ||
PHPENV_DIR="$(pwd)" | ||
cd "$OLDPWD" | ||
fi | ||
export PHPENV_DIR | ||
|
||
|
||
shopt -s nullglob | ||
|
||
bin_path="$(abs_dirname "$0")" | ||
for plugin_bin in "${PHPENV_ROOT}/plugins/"*/bin; do | ||
bin_path="${bin_path}:${plugin_bin}" | ||
done | ||
export PATH="${bin_path}:${PATH}" | ||
|
||
hook_path="${PHPENV_HOOK_PATH}:${PHPENV_ROOT}/phpenv.d:/usr/local/etc/phpenv.d:/etc/phpenv.d:/usr/lib/phpenv/hooks" | ||
for plugin_hook in "${PHPENV_ROOT}/plugins/"*/etc/phpenv.d; do | ||
hook_path="${hook_path}:${plugin_hook}" | ||
done | ||
export PHPENV_HOOK_PATH="$hook_path" | ||
|
||
shopt -u nullglob | ||
|
||
command="$1" | ||
if [[ "$2" = "--help" || "$2" = "-h" ]]; then | ||
phpenv-help "$command" >&2 | ||
exit 1 | ||
fi | ||
|
||
case "$command" in | ||
"" | "-h" | "--help" ) | ||
echo -e "$(phpenv-help)" >&2 | ||
;; | ||
"-v" ) | ||
exec phpenv---version | ||
;; | ||
* ) | ||
command_path="$(command -v "phpenv-$command" || true)" | ||
if [ -z "$command_path" ]; then | ||
echo "phpenv: no such command \`$command'" >&2 | ||
exit 1 | ||
fi | ||
|
||
shift 1 | ||
exec "$command_path" "$@" | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
# Summary: Display the version of phpenv | ||
# | ||
# Displays the version number of this phpenv release, including the | ||
# current revision from git, if available. | ||
# | ||
# The format of the git revision is: | ||
# <version>-<num_commits>-<git_sha> | ||
# where `num_commits` is the number of commits since `version` was | ||
# tagged. | ||
|
||
set -e | ||
[ -n "$PHPENV_DEBUG" ] && set -x | ||
|
||
version="0.9.0-rc.1" | ||
git_revision="" | ||
|
||
cd "$PHPENV_ROOT" | ||
git_revision="$(git describe --tags HEAD 2>/dev/null || true)" | ||
git_revision="${git_revision#v}" | ||
|
||
echo "phpenv v${git_revision:-$version}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
# Usage: phpenv completions <command> [arg1 arg2...] | ||
|
||
set -e | ||
[ -n "$PHPENV_DEBUG" ] && set -x | ||
|
||
COMMAND="$1" | ||
if [ -z "$COMMAND" ]; then | ||
phpenv-help --usage completions >&2 | ||
exit 1 | ||
fi | ||
|
||
COMMAND_PATH="$(command -v "phpenv-$COMMAND" || command -v "phpenv-sh-$COMMAND")" | ||
if grep -i "^# provide phpenv completions" "$COMMAND_PATH" >/dev/null; then | ||
shift | ||
exec "$COMMAND_PATH" --complete "$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
# Summary: Edit the current PHP's php.ini configuration file at location | ||
|
||
set -e | ||
[ -n "$PHPENV_DEBUG" ] && set -x | ||
|
||
if [ "$VISUAL" ]; then | ||
cmd="$VISUAL" | ||
fi | ||
|
||
if ! [ "$cmd" ] && [ "$EDITOR" ]; then | ||
cmd="$EDITOR" | ||
fi | ||
|
||
if ! [ "$cmd" ] && type vim >/dev/null 2>&1; then | ||
cmd="vim" | ||
fi | ||
|
||
if ! [ "$cmd" ]; then | ||
cmd="vi" | ||
fi | ||
|
||
"$cmd" "$(php --ini|grep Loaded|awk '{print $NF}')" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Summary: Run an executable with the selected PHP version | ||
# | ||
# Usage: phpenv exec <command> [arg1 arg2...] | ||
# | ||
# Runs an executable by first preparing PATH so that the selected PHP | ||
# version's `bin' directory is at the front. | ||
# | ||
# For example, if the currently selected PHP version is 1.9.3-p327: | ||
# phpenv exec bundle install | ||
# | ||
# is equivalent to: | ||
# PATH="$PHPENV_ROOT/versions/1.9.3-p327/bin:$PATH" bundle install | ||
|
||
set -e | ||
[ -n "$PHPENV_DEBUG" ] && set -x | ||
|
||
# Provide phpenv completions | ||
if [ "$1" = "--complete" ]; then | ||
exec phpenv shims --short | ||
fi | ||
|
||
export PHPENV_VERSION="$(phpenv-version-name)" | ||
PHPENV_COMMAND="$1" | ||
|
||
if [ -z "$PHPENV_COMMAND" ]; then | ||
phpenv-help --usage exec >&2 | ||
exit 1 | ||
fi | ||
|
||
PHPENV_COMMAND_PATH="$(phpenv-which "$PHPENV_COMMAND")" | ||
PHPENV_BIN_PATH="${PHPENV_COMMAND_PATH%/*}" | ||
|
||
for script in $(phpenv-hooks exec); do | ||
source "$script" | ||
done | ||
|
||
shift 1 | ||
if [ "$PHPENV_VERSION" != "system" ]; then | ||
export PATH="${PHPENV_BIN_PATH}:${PATH}" | ||
fi | ||
exec -a "$PHPENV_COMMAND" "$PHPENV_COMMAND_PATH" "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Summary: Set or show the global PHP version and update the Apache apxs | ||
# library link | ||
# | ||
# Usage: phpenv global <version> | ||
# phpenv global --unset | ||
# | ||
# Sets the global PHP version. You can override the global version at | ||
# any time by setting a directory-specific version with `phpenv local' | ||
# or by setting the `PHPENV_VERSION' environment variable. | ||
# | ||
# <version> should be a string matching a PHP version known to phpenv. | ||
# The special version string `system' will use your default system PHP. | ||
# Run `phpenv versions' for a list of available PHP versions. | ||
|
||
set -e | ||
[ -n "$PHPENV_DEBUG" ] && set -x | ||
|
||
# Provide phpenv completions | ||
if [ "$1" = "--complete" ]; then | ||
echo system --unset | ||
exec phpenv-versions --bare | ||
fi | ||
|
||
PHPENV_VERSION="$1" | ||
PHPENV_VERSION_FILE="${PHPENV_ROOT}/version" | ||
|
||
if [ "$1" == "--unset" ]; then | ||
rm -f "$PHPENV_VERSION_FILE" | ||
PHPENV_VERSION="" | ||
fi | ||
|
||
if [ -n "$PHPENV_VERSION" ]; then | ||
phpenv-version-file-write "$PHPENV_VERSION_FILE" "$PHPENV_VERSION" | ||
else | ||
PHPENV_VERSION=$(phpenv-version-file-read "$PHPENV_VERSION_FILE") || | ||
PHPENV_VERSION=$(phpenv-version-file-read "${PHPENV_ROOT}/global") || | ||
PHPENV_VERSION=$(phpenv-version-file-read "${PHPENV_ROOT}/default") || | ||
PHPENV_VERSION=system | ||
fi | ||
|
||
echo ${PHPENV_VERSION} | ||
|
||
# Link Apache apxs lib | ||
rm -f "${PHPENV_ROOT}"/lib/libphp*.so | ||
LIBPHP_SO_FILE="libphp$(php-config --version | cut -c1).so" | ||
APXS="" | ||
if [ "${PHPENV_VERSION}" == "system" ]; then | ||
DEFAULT_APXS="$(which apxs 2>/dev/null)" | ||
if [ -n "${DEFAULT_APXS}" -a -f "$(${DEFAULT_APXS} -q LIBEXECDIR)/${LIBPHP_SO_FILE}" ]; then | ||
APXS="${DEFAULT_APXS}" | ||
fi | ||
fi | ||
php-config --configure-options 2>/dev/null | grep -q apxs && \ | ||
APXS="$(php-config --configure-options| sed 's/.*=\(.*apxs[^ ]*\) .*/\1/')" | ||
|
||
[[ -d "${PHPENV_ROOT}/lib" ]] || mkdir "${PHPENV_ROOT}/lib" | ||
if [ -n "${APXS}" ]; then | ||
[[ "${PHPENV_VERSION}" == "system" ]] && \ | ||
ln -fs "$(${APXS} -q LIBEXECDIR)/${LIBPHP_SO_FILE}" "${PHPENV_ROOT}/lib/${LIBPHP_SO_FILE}" || \ | ||
ln -fs "${PHPENV_ROOT}/versions/${PHPENV_VERSION}/libexec/${LIBPHP_SO_FILE}" "${PHPENV_ROOT}/lib/${LIBPHP_SO_FILE}"; | ||
fi |
Oops, something went wrong.