Install PHP only if not found and support 7.4.0RC2

This commit is contained in:
Shivam Mathur 2019-09-17 20:40:27 +05:30
parent 69f9b777e1
commit a398f54da4
6 changed files with 69 additions and 43 deletions

View File

@ -8,7 +8,7 @@ jobs:
max-parallel: 6 max-parallel: 6
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@master uses: actions/checkout@master

View File

@ -13,7 +13,7 @@
- 7.1 - 7.1
- 7.2 - 7.2
- 7.3 - 7.3
- 7.4 `7.4.0beta4` on `ubuntu`, and `7.4.0RC1` on `windows` and `macOS` - 7.4 `7.4.0beta4` on `ubuntu`, and `7.4.0RC2` on `windows` and `macOS`
**Note:** PHP 7.4 is currently in development, do not use in production. **Note:** PHP 7.4 is currently in development, do not use in production.

View File

@ -41,8 +41,8 @@ sudo mkdir -p /opt/phpbrew
phpbrew init --root=/opt/phpbrew phpbrew init --root=/opt/phpbrew
echo "[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc" >> ~/.bashrc echo "[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc" >> ~/.bashrc
source ~/.bashrc source ~/.bashrc
phpbrew install -j 10 7.4.0RC1 +default +bz2="$(brew --prefix bzip2)" +zlib="$(brew --prefix zlib)" -openssl -- --with-libxml phpbrew install -j 10 7.4.0RC2 +default +bz2="$(brew --prefix bzip2)" +zlib="$(brew --prefix zlib)" -openssl -- --with-libxml
phpbrew switch php-7.4.0RC1 >> /dev/null phpbrew switch php-7.4.0RC2 >> /dev/null
sudo mkdir -p /usr/local/bin sudo mkdir -p /usr/local/bin
sudo ln -sf /Users/runner/.phpbrew/php/php-7.4.0RC1/bin/php /usr/local/bin/php sudo ln -sf /Users/runner/.phpbrew/php/php-7.4.0RC2/bin/php /usr/local/bin/php
brew install composer brew install composer

View File

@ -1,8 +1,11 @@
echo $1 version=$(php-config --version | cut -c 1-3)
brew unlink php if [ "$version" != "$1" ]; then
brew tap exolnet/homebrew-deprecated brew tap exolnet/homebrew-deprecated;
brew install php@$1 brew unlink php;
brew link --force --overwrite php@$1 brew install php@$1;
brew link --force --overwrite php@$1;
fi
curl -sS https://getcomposer.org/installer | php curl -sS https://getcomposer.org/installer | php
chmod +x composer.phar chmod +x composer.phar
mv composer.phar /usr/local/bin/composer mv composer.phar /usr/local/bin/composer

View File

@ -1,10 +1,26 @@
ua()
{
for tool in php phar phar.phar php-cgi php-config phpize; do
if [ -e "/usr/bin/$tool$version" ]; then
sudo update-alternatives --set $tool /usr/bin/$tool$1;
fi
done
}
version=$(php-config --version | cut -c 1-3)
if [ "$version" != "$1" ]; then
if [ ! -e "/usr/bin/php$1" ]; then
sudo add-apt-repository ppa:ondrej/php -y sudo add-apt-repository ppa:ondrej/php -y
sudo apt update -y sudo apt update -y
sudo mkdir -p /run/php sudo apt install -y php$1 curl;
sudo apt install -y php$1 curl sudo apt autoremove -y;
sudo apt autoremove -y fi
sudo update-alternatives --set php /usr/bin/php$1 ua $1;
sudo curl -s https://getcomposer.org/installer | php fi
sudo mv composer.phar /usr/local/bin/composer
if [ ! -e "/usr/bin/composer" ]; then
sudo curl -s https://getcomposer.org/installer | php;
sudo mv composer.phar /usr/local/bin/composer;
fi
php -v php -v
composer -V composer -V

View File

@ -3,11 +3,17 @@ param (
) )
if($version -eq '7.4') { if($version -eq '7.4') {
$version = '7.4RC1' $version = '7.4RC'
} }
echo "Installing NuGet" echo "Installing NuGet"
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
echo "Installing PhpManager"
Install-Module -Name PhpManager -Force -Scope CurrentUser
$installed = php -v | grep ^PHP | cut -c 5-7
echo $installed
echo $version
if($installed -ne $version) {
if($version -lt '7.0') { if($version -lt '7.0') {
echo "Installing Visual C++" echo "Installing Visual C++"
Install-Module -Name VcRedist -Force Install-Module -Name VcRedist -Force
@ -16,8 +22,7 @@ if($version -lt '7.0') {
$VcList = Get-VcList $VcList = Get-VcList
Install-VcRedist -Path C:\Temp\VcRedist -VcList $VcList -Silent Install-VcRedist -Path C:\Temp\VcRedist -VcList $VcList -Silent
} }
echo "Installing PhpManager"
Install-Module -Name PhpManager -Force -Scope CurrentUser
echo "Installing PHP" echo "Installing PHP"
Uninstall-Php C:\tools\php Uninstall-Php C:\tools\php
Install-Php -Version $version -Architecture x86 -ThreadSafe $true -Path C:\tools\php$version -TimeZone UTC -InitialPhpIni Production Install-Php -Version $version -Architecture x86 -ThreadSafe $true -Path C:\tools\php$version -TimeZone UTC -InitialPhpIni Production
@ -34,6 +39,8 @@ if($version -lt '7.4') {
} else { } else {
Add-Content C:\tools\php$version\php.ini "extension=php_openssl.dll" Add-Content C:\tools\php$version\php.ini "extension=php_openssl.dll"
} }
}
echo "Installing Composer" echo "Installing Composer"
Install-Composer -Scope System -Path C:\tools\php Install-Composer -Scope System -Path C:\tools\php
php -v php -v