Skip to content

Commit

Permalink
Update phpenv to 0.9.0-rc.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mhart committed Dec 31, 2018
1 parent 0a146e9 commit 0d386d3
Show file tree
Hide file tree
Showing 51 changed files with 933 additions and 1,007 deletions.
5 changes: 4 additions & 1 deletion home/.phpenv/LICENSE
@@ -1,4 +1,6 @@
Copyright (c) 2013 Sam Stephenson
Copyright (c) 2012 Dominic Giglio
Copyright (c) 2013 Nick Lombard
Copyright (c) 2015 madumlao

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand All @@ -18,3 +20,4 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

4 changes: 0 additions & 4 deletions home/.phpenv/bin/phpenv

This file was deleted.

1 change: 1 addition & 0 deletions home/.phpenv/bin/phpenv
1 change: 0 additions & 1 deletion home/.phpenv/bin/rbenv

This file was deleted.

16 changes: 16 additions & 0 deletions home/.phpenv/completions/phpenv.bash
@@ -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
22 changes: 22 additions & 0 deletions home/.phpenv/completions/phpenv.fish
@@ -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
18 changes: 18 additions & 0 deletions home/.phpenv/completions/phpenv.zsh
@@ -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}")
}
92 changes: 92 additions & 0 deletions home/.phpenv/libexec/phpenv
@@ -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
22 changes: 22 additions & 0 deletions home/.phpenv/libexec/phpenv---version
@@ -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}"
@@ -1,11 +1,11 @@
#!/usr/bin/env bash
# Summary: List all available rbenv commands
# Usage: rbenv commands [--sh|--no-sh]
# Summary: List all available phpenv commands
# Usage: phpenv commands [--sh|--no-sh]

set -e
[ -n "$RBENV_DEBUG" ] && set -x
[ -n "$PHPENV_DEBUG" ] && set -x

# Provide rbenv completions
# Provide phpenv completions
if [ "$1" = "--complete" ]; then
echo --sh
echo --no-sh
Expand All @@ -20,13 +20,11 @@ elif [ "$1" = "--no-sh" ]; then
shift
fi

IFS=: paths=($PATH)

shopt -s nullglob

{ for path in "${paths[@]}"; do
for command in "${path}/rbenv-"*; do
command="${command##*rbenv-}"
{ for path in ${PATH//:/$'\n'}; do
for command in "${path}/phpenv-"*; do
command="${command##*phpenv-}"
if [ -n "$sh" ]; then
if [ ${command:0:3} = "sh-" ]; then
echo ${command##sh-}
Expand Down
17 changes: 17 additions & 0 deletions home/.phpenv/libexec/phpenv-completions
@@ -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
23 changes: 23 additions & 0 deletions home/.phpenv/libexec/phpenv-configure
@@ -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}')"
43 changes: 43 additions & 0 deletions home/.phpenv/libexec/phpenv-exec
@@ -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" "$@"
63 changes: 63 additions & 0 deletions home/.phpenv/libexec/phpenv-global
@@ -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

0 comments on commit 0d386d3

Please sign in to comment.