From d169101fe8ebb90073febe64f1120bb48d5ac084 Mon Sep 17 00:00:00 2001 From: Diana Scharf Date: Tue, 27 Oct 2026 18:41:13 +0100 Subject: [PATCH] Install SPX for every Herd PHP version that has a build The installer only looped over PHP 7.4-8.4 and checked the default php binary at the end, so it reported a failure when Herd's default PHP was 8.5, even though SPX had installed fine for 8.2-8.4. Loop over the php binaries Herd actually has, skip versions without a release build instead of writing a broken extension= line, and verify each installed version separately. Refs beyondcode/herd-community#1788 --- install.sh | 58 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/install.sh b/install.sh index fb87dc71..6fc5e5e7 100755 --- a/install.sh +++ b/install.sh @@ -51,6 +51,12 @@ error() { LATEST_RELEASE=$(curl -s $REPO_URL | grep -o '"tag_name": *"[^"]*"' | sed 's/.*": *"\([^"]*\)".*/\1/') echo "" + +if [[ -z $LATEST_RELEASE ]]; then + error "Could not determine the latest SPX release." + exit 1 +fi + info "Latest release: $LATEST_RELEASE" @@ -65,8 +71,11 @@ download_and_extract() { info "Downloading $zip_file..." - curl -L -o "$target_dir/$zip_file" $file_url - + if ! curl -fsL -o "$target_dir/$zip_file" "$file_url"; then + rm -f "$target_dir/$zip_file" + return 1 + fi + info "Extracting $zip_file..." unzip -o "$target_dir/$zip_file" -d "$target_dir/spx" > /dev/null @@ -74,7 +83,8 @@ download_and_extract() { if [[ ! -f "$target_dir/spx/$so_file" ]]; then echo "There was an error extracting the extension." echo "$so_file not found in $target_dir/spx" - exit 1 + rm -f "$target_dir/$zip_file" + return 1 fi # Remove the quarantine attribute (might not be needed when the repo is public) @@ -93,8 +103,11 @@ fi if [[ $HERD_INSTALLED -eq 1 ]]; then info "Laravel Herd is installed. Installing for all available PHP versions..." - for version in {74..84}; do - PHP_BIN="$HERD_BIN_DIR/php$version" + INSTALLED=() + UNSUPPORTED=() + + for PHP_BIN in "$HERD_BIN_DIR"/php[0-9][0-9]; do + version=${PHP_BIN##*/php} CONFIG_DIR="$HERD_CONFIG_DIR/$version" if [[ -f $PHP_BIN ]]; then PHP_VERSION_STRING="${version:0:1}.${version:1}" @@ -106,9 +119,12 @@ if [[ $HERD_INSTALLED -eq 1 ]]; then # Check if the extension is already in php.ini if ! grep -q "extension=$SO_FILE" "$PHP_INI_PATH"; then info "Installing for PHP $PHP_VERSION_STRING..." - + # Download and extract the .so file - _=$(download_and_extract $version $PHP_VERSION_STRING) + if ! download_and_extract $version $PHP_VERSION_STRING > /dev/null; then + UNSUPPORTED+=("$PHP_VERSION_STRING") + continue + fi { echo "" @@ -127,11 +143,23 @@ if [[ $HERD_INSTALLED -eq 1 ]]; then info "Skipping, already installed…" fi fi + + INSTALLED+=("$PHP_VERSION_STRING") fi done + if [[ ${#UNSUPPORTED[@]} -gt 0 ]]; then + info "No SPX build for PHP ${UNSUPPORTED[*]} yet, skipped." + fi + + if [[ ${#INSTALLED[@]} -eq 0 ]]; then + error "There was an error installing the extension." + error "No supported PHP version found." + exit 1 + fi + info "Restarting Laravel Herd..." - + if [[ $VERBOSE -eq 1 ]]; then herd restart else @@ -139,14 +167,20 @@ if [[ $HERD_INSTALLED -eq 1 ]]; then fi # Validate the installation - SPX_INSTALLED=$(php -m | grep SPX) - if [[ -z $SPX_INSTALLED ]]; then - error "There was an error installing the extension." + FAILED=() + for PHP_VERSION_STRING in "${INSTALLED[@]}"; do + if ! "$HERD_BIN_DIR/php${PHP_VERSION_STRING/./}" -m | grep -q SPX; then + FAILED+=("$PHP_VERSION_STRING") + fi + done + + if [[ ${#FAILED[@]} -gt 0 ]]; then + error "There was an error installing the extension for PHP ${FAILED[*]}." error "Please check the output above for any errors." exit 1 fi - success "SPX Profiler extension installed successfully." + success "SPX Profiler installed for PHP ${INSTALLED[*]}." else error "Laravel Herd is not installed. Exiting..." error "Please follow the manual installation instructions on the GitHub repository."