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 @@
sudo add-apt-repository ppa:ondrej/php -y ua()
sudo apt update -y {
sudo mkdir -p /run/php for tool in php phar phar.phar php-cgi php-config phpize; do
sudo apt install -y php$1 curl if [ -e "/usr/bin/$tool$version" ]; then
sudo apt autoremove -y sudo update-alternatives --set $tool /usr/bin/$tool$1;
sudo update-alternatives --set php /usr/bin/php$1 fi
sudo curl -s https://getcomposer.org/installer | php done
sudo mv composer.phar /usr/local/bin/composer }
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 apt update -y
sudo apt install -y php$1 curl;
sudo apt autoremove -y;
fi
ua $1;
fi
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,37 +3,44 @@ 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
if($version -lt '7.0') {
echo "Installing Visual C++"
Install-Module -Name VcRedist -Force
New-Item -Path C:\Temp\VcRedist -ItemType Directory
Get-VcList | Save-VcRedist -Path C:\Temp\VcRedist
$VcList = Get-VcList
Install-VcRedist -Path C:\Temp\VcRedist -VcList $VcList -Silent
}
echo "Installing PhpManager" echo "Installing PhpManager"
Install-Module -Name PhpManager -Force -Scope CurrentUser Install-Module -Name PhpManager -Force -Scope CurrentUser
echo "Installing PHP"
Uninstall-Php C:\tools\php $installed = php -v | grep ^PHP | cut -c 5-7
Install-Php -Version $version -Architecture x86 -ThreadSafe $true -Path C:\tools\php$version -TimeZone UTC -InitialPhpIni Production echo $installed
echo "Switch PHP" echo $version
(Get-PhpSwitcher).targets if($installed -ne $version) {
Initialize-PhpSwitcher -Alias C:\tools\php -Scope CurrentUser -Force if($version -lt '7.0') {
Add-PhpToSwitcher -Name $version -Path C:\tools\php$version -Force echo "Installing Visual C++"
Switch-Php $version -Force Install-Module -Name VcRedist -Force
echo "Housekeeping in PHP.ini, enabling openssl" New-Item -Path C:\Temp\VcRedist -ItemType Directory
Add-Content C:\tools\php$version\php.ini "date.timezone = 'UTC'" Get-VcList | Save-VcRedist -Path C:\Temp\VcRedist
Set-PhpIniKey extension_dir C:\tools\php$version\ext $VcList = Get-VcList
if($version -lt '7.4') { Install-VcRedist -Path C:\Temp\VcRedist -VcList $VcList -Silent
Enable-PhpExtension openssl }
} else {
Add-Content C:\tools\php$version\php.ini "extension=php_openssl.dll" echo "Installing PHP"
Uninstall-Php C:\tools\php
Install-Php -Version $version -Architecture x86 -ThreadSafe $true -Path C:\tools\php$version -TimeZone UTC -InitialPhpIni Production
echo "Switch PHP"
(Get-PhpSwitcher).targets
Initialize-PhpSwitcher -Alias C:\tools\php -Scope CurrentUser -Force
Add-PhpToSwitcher -Name $version -Path C:\tools\php$version -Force
Switch-Php $version -Force
echo "Housekeeping in PHP.ini, enabling openssl"
Add-Content C:\tools\php$version\php.ini "date.timezone = 'UTC'"
Set-PhpIniKey extension_dir C:\tools\php$version\ext
if($version -lt '7.4') {
Enable-PhpExtension openssl
} else {
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