Skip to content

Instantly share code, notes, and snippets.

@Wirone
Last active November 14, 2025 16:01
Show Gist options
  • Select an option

  • Save Wirone/b84fea95f01376221903727a860f74b7 to your computer and use it in GitHub Desktop.

Select an option

Save Wirone/b84fea95f01376221903727a860f74b7 to your computer and use it in GitHub Desktop.
Install PIE (PHP's extension installer) into every ASDF's PHP version
#!/usr/bin/env bash
set -euo pipefail
# Config
ASDF_PHP_DIR="${HOME}/.asdf/installs/php"
PIE_URL="https://github.com/php/pie/releases/latest/download/pie.phar"
echo "Downloading latest pie.phar from ${PIE_URL} (non-prerelease)..."
TMP_PIE="$(mktemp)"
curl -fsSL -o "${TMP_PIE}" "${PIE_URL}"
if [[ ! -s "${TMP_PIE}" ]]; then
echo "Error: Downloaded pie.phar is empty or missing."
exit 1
fi
if [[ ! -d "${ASDF_PHP_DIR}" ]]; then
echo "Error: ASDF PHP directory not found at ${ASDF_PHP_DIR}"
rm -f "${TMP_PIE}"
exit 1
fi
echo "Installing PIE into each PHP bin directory under ${ASDF_PHP_DIR}..."
found_any=false
for php_version_dir in "${ASDF_PHP_DIR}"/*; do
if [[ -d "${php_version_dir}" ]]; then
bin_dir="${php_version_dir}/bin"
mkdir -p "${bin_dir}"
install_path="${bin_dir}/pie"
cp "${TMP_PIE}" "${install_path}"
chmod +x "${install_path}"
echo " Installed pie to ${install_path}"
found_any=true
fi
done
rm -f "${TMP_PIE}"
if [[ "${found_any}" = false ]]; then
echo "Warning: No PHP installations found under ${ASDF_PHP_DIR}"
exit 0
fi
echo "Running 'asdf reshim php'..."
if command -v asdf >/dev/null 2>&1; then
asdf reshim php
else
echo "Warning: 'asdf' not found; skipping 'asdf reshim php'."
fi
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment