@@ -51,6 +51,12 @@ error() {
5151LATEST_RELEASE=$( curl -s $REPO_URL | grep -o ' "tag_name": *"[^"]*"' | sed ' s/.*": *"\([^"]*\)".*/\1/' )
5252
5353echo " "
54+
55+ if [[ -z $LATEST_RELEASE ]]; then
56+ error " Could not determine the latest SPX release."
57+ exit 1
58+ fi
59+
5460info " Latest release: $LATEST_RELEASE "
5561
5662
@@ -65,16 +71,20 @@ download_and_extract() {
6571
6672 info " Downloading $zip_file ..."
6773
68- curl -L -o " $target_dir /$zip_file " $file_url
69-
74+ if ! curl -fsL -o " $target_dir /$zip_file " " $file_url " ; then
75+ rm -f " $target_dir /$zip_file "
76+ return 1
77+ fi
78+
7079 info " Extracting $zip_file ..."
7180 unzip -o " $target_dir /$zip_file " -d " $target_dir /spx" > /dev/null
7281
7382 # Make sure the .so file exists
7483 if [[ ! -f " $target_dir /spx/$so_file " ]]; then
7584 echo " There was an error extracting the extension."
7685 echo " $so_file not found in $target_dir /spx"
77- exit 1
86+ rm -f " $target_dir /$zip_file "
87+ return 1
7888 fi
7989
8090 # Remove the quarantine attribute (might not be needed when the repo is public)
93103
94104if [[ $HERD_INSTALLED -eq 1 ]]; then
95105 info " Laravel Herd is installed. Installing for all available PHP versions..."
96- for version in {74..84}; do
97- PHP_BIN=" $HERD_BIN_DIR /php$version "
106+ INSTALLED=()
107+ UNSUPPORTED=()
108+
109+ for PHP_BIN in " $HERD_BIN_DIR " /php[0-9][0-9]; do
110+ version=${PHP_BIN##*/ php}
98111 CONFIG_DIR=" $HERD_CONFIG_DIR /$version "
99112 if [[ -f $PHP_BIN ]]; then
100113 PHP_VERSION_STRING=" ${version: 0: 1} .${version: 1} "
@@ -106,9 +119,12 @@ if [[ $HERD_INSTALLED -eq 1 ]]; then
106119 # Check if the extension is already in php.ini
107120 if ! grep -q " extension=$SO_FILE " " $PHP_INI_PATH " ; then
108121 info " Installing for PHP $PHP_VERSION_STRING ..."
109-
122+
110123 # Download and extract the .so file
111- _=$( download_and_extract $version $PHP_VERSION_STRING )
124+ if ! download_and_extract $version $PHP_VERSION_STRING > /dev/null; then
125+ UNSUPPORTED+=(" $PHP_VERSION_STRING " )
126+ continue
127+ fi
112128
113129 {
114130 echo " "
@@ -127,26 +143,44 @@ if [[ $HERD_INSTALLED -eq 1 ]]; then
127143 info " Skipping, already installed…"
128144 fi
129145 fi
146+
147+ INSTALLED+=(" $PHP_VERSION_STRING " )
130148 fi
131149 done
132150
151+ if [[ ${# UNSUPPORTED[@]} -gt 0 ]]; then
152+ info " No SPX build for PHP ${UNSUPPORTED[*]} yet, skipped."
153+ fi
154+
155+ if [[ ${# INSTALLED[@]} -eq 0 ]]; then
156+ error " There was an error installing the extension."
157+ error " No supported PHP version found."
158+ exit 1
159+ fi
160+
133161 info " Restarting Laravel Herd..."
134-
162+
135163 if [[ $VERBOSE -eq 1 ]]; then
136164 herd restart
137165 else
138166 herd restart > /dev/null
139167 fi
140168
141169 # Validate the installation
142- SPX_INSTALLED=$( php -m | grep SPX)
143- if [[ -z $SPX_INSTALLED ]]; then
144- error " There was an error installing the extension."
170+ FAILED=()
171+ for PHP_VERSION_STRING in " ${INSTALLED[@]} " ; do
172+ if ! " $HERD_BIN_DIR /php${PHP_VERSION_STRING/ ./ } " -m | grep -q SPX; then
173+ FAILED+=(" $PHP_VERSION_STRING " )
174+ fi
175+ done
176+
177+ if [[ ${# FAILED[@]} -gt 0 ]]; then
178+ error " There was an error installing the extension for PHP ${FAILED[*]} ."
145179 error " Please check the output above for any errors."
146180 exit 1
147181 fi
148182
149- success " SPX Profiler extension installed successfully ."
183+ success " SPX Profiler installed for PHP ${INSTALLED[*]} ."
150184else
151185 error " Laravel Herd is not installed. Exiting..."
152186 error " Please follow the manual installation instructions on the GitHub repository."
0 commit comments