File tree Expand file tree Collapse file tree 1 file changed +38
-1
lines changed
Expand file tree Collapse file tree 1 file changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -203,6 +203,41 @@ function maybe_run_node_build() {
203203 fi
204204}
205205
206+ function maybe_install_php_dep() {
207+
208+ VALID_PHP_VERSIONS=(" 7.4" " 8.0" " 8.1" " 8.2" " 8.3" " 8.4" )
209+ if [[ -z " $PHP_VERSION " ]]; then
210+ echo " No PHP version specified. Skipping PHP setup."
211+ return
212+ fi
213+
214+ if [[ ! " ${VALID_PHP_VERSIONS[@]} " =~ " ${PHP_VERSION} " ]]; then
215+ echo " Invalid PHP version specified: $PHP_VERSION "
216+ echo " Valid versions are: ${VALID_PHP_VERSIONS[*]} "
217+ exit 1
218+ fi
219+
220+ apt install -y software-properties-common && \
221+ add-apt-repository ppa:ondrej/php && \
222+ apt update && \
223+ apt-get install -y php" $PHP_VERSION " -cli php" $PHP_VERSION " -curl php" $PHP_VERSION " -mbstring php" $PHP_VERSION " -xml php" $PHP_VERSION " -iconv php" $PHP_VERSION " -yaml
224+
225+ update-alternatives --set php /usr/bin/php${PHP_VERSION}
226+ }
227+
228+ function maybe_run_php_build() {
229+
230+ [[ -n " $PHP_BUILD_DIRECTORY " ]] && cd " $PHP_BUILD_DIRECTORY "
231+ [[ -n " $PHP_BUILD_COMMAND " ]] && eval " $PHP_BUILD_COMMAND "
232+
233+ if [[ -n " $PHP_BUILD_SCRIPT " ]]; then
234+ chmod +x " $PHP_BUILD_SCRIPT "
235+ ./" $PHP_BUILD_SCRIPT "
236+ fi
237+
238+ update-alternatives --set php /usr/bin/php${DEFAULT_PHP_VERSION}
239+ }
240+
206241function setup_wordpress_files() {
207242
208243 mkdir -p " $HTDOCS "
@@ -332,9 +367,11 @@ function main() {
332367 setup_hosts_file
333368 check_branch_in_hosts_file
334369 setup_ssh_access
370+ maybe_install_submodules
335371 maybe_install_node_dep
336372 maybe_run_node_build
337- maybe_install_submodules
373+ maybe_install_php_dep
374+ maybe_run_php_build
338375 setup_wordpress_files
339376 block_emails
340377 deploy
You can’t perform that action at this time.
0 commit comments