Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit 469f51d

Browse files
author
Antonios Papadakis
committed
Split up Steps Into Functions
macOS
1 parent 93aeae0 commit 469f51d

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

macos/install.sh

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

3-
function compilePHP {
3+
# Pre-install setup (install version choice, brew install, decompress files, cd into directory, etc.)
4+
function setup {
45
# Install All Dependencies
56
read -p 'Which PHP version would you like to install?[latest-7.1/latest-7.2/latest-7.3/default: latest-7.4/latest-8.0/latest-master] ' PHPINSTALLVERSION
67
PHPINSTALLVERSION=${PHPINSTALLVERSION:-latest-7.4}
@@ -56,8 +57,6 @@ function compilePHP {
5657
sudo echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' | sudo tee ~/.bash_profile
5758
source ~/.bash_profile
5859
echo Installed all Dependencies
59-
# Build the Configure Script
60-
echo Building configuration script
6160

6261
if [ "$PHPINSTALLVERSION" = latest-7.1 ]; then
6362
cd php-src-php-7.1.32/ || exit
@@ -72,7 +71,11 @@ function compilePHP {
7271
elif [ "$PHPINSTALLVERSION" = latest-master ]; then
7372
cd ..
7473
fi
74+
}
7575

76+
# Configure PHP (./buildconf and ./configure)
77+
function configure {
78+
echo Building configuration script
7679
sudo ./buildconf --force || exit
7780
echo Built Configuration Script
7881
# Configure PHP Installation
@@ -89,6 +92,10 @@ function compilePHP {
8992
sudo ./configure --with-openssl --enable-bcmath --enable-calendar --with-curl --enable-ftp --with-mhash --without-iconv --with-imap-ssl --enable-mbstring --enable-pdo --with-pdo-mysql=mysqlnd --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm || exit
9093
fi
9194
echo Configured PHP
95+
}
96+
97+
# Build PHP (make)
98+
function build {
9299
# Set the Job Count for make
93100
echo Setting job count for make
94101
THREADCOUNT=$(sysctl -n hw.ncpu)
@@ -98,8 +105,10 @@ function compilePHP {
98105
echo Building PHP
99106
sudo make -j"$JOBCOUNT" || exit
100107
echo Built PHP
108+
}
101109

102-
# Test PHP Commands and Test for Bugs
110+
# Test PHP (make test)
111+
function test {
103112
echo Testing PHP
104113
if [ "$PHPINSTALLVERSION" = latest-8.0 ] || [ "$PHPINSTALLVERSION" = latest-master ] || [ "$PHPINSTALLVERSION" = latest-7.4 ]; then
105114
sudo make TEST_PHP_ARGS=-j"$JOBCOUNT" test
@@ -112,6 +121,10 @@ function compilePHP {
112121
fi
113122

114123
echo Tested PHP
124+
}
125+
126+
# Install PHP CLI (make install)
127+
function installCLI {
115128
read -p 'The tests have been completed and you may or may not have had failures on some of them. This can sometimes be ignored with the latest builds, or may need extra attention. Would you like to continue with installation?[default: y/Y/n/N] ' ERRORRESPONSE
116129
ERRORRESPONSE=${ERRORRESPONSE:-y}
117130
if [ "$ERRORRESPONSE" = y ] || [ "$ERRORRESPONSE" = Y ]; then
@@ -131,13 +144,21 @@ function compilePHP {
131144
BREWCHECK=$?
132145

133146
if [ "$BREWCHECK" = 0 ]; then
134-
compilePHP
147+
setup
148+
configure
149+
build
150+
test
151+
installCLI
135152
elif [ "$BREWCHECK" = 127 ]; then
136153
# Install Homebew Since it was not Found
137-
echo installing brew
154+
echo installing Homebrew
138155
sudo /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
139-
echo brew has been installed
140-
compilePHP
156+
echo Homebrew has been installed
157+
setup
158+
configure
159+
build
160+
test
161+
installCLI
141162
else
142163
echo There was an error checking for Homebrew support.
143164
git checkout master

0 commit comments

Comments
 (0)