Add support for old PHP versions on windows

This commit is contained in:
Shivam Mathur 2020-02-06 05:24:45 +05:30
parent 326dfd1e76
commit 3c6644f237
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A

View File

@ -91,10 +91,7 @@ Function Add-Tool() {
if (Test-Path $php_dir\$tool) { if (Test-Path $php_dir\$tool) {
Remove-Item $php_dir\$tool Remove-Item $php_dir\$tool
} }
if ($tool -eq "composer") { if ($tool -eq "symfony") {
Install-Composer -Scope System -Path $php_dir -PhpPath $php_dir
composer -q global config process-timeout 0
} elseif ($tool -eq "symfony") {
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool.exe Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool.exe
Add-Content -Path $PsHome\profile.ps1 -Value "New-Alias $tool $php_dir\$tool.exe" > $null 2>&1 Add-Content -Path $PsHome\profile.ps1 -Value "New-Alias $tool $php_dir\$tool.exe" > $null 2>&1
} else { } else {
@ -113,9 +110,10 @@ Function Add-Tool() {
Add-Extension curl >$null 2>&1 Add-Extension curl >$null 2>&1
Add-Extension mbstring >$null 2>&1 Add-Extension mbstring >$null 2>&1
Add-Extension xml >$null 2>&1 Add-Extension xml >$null 2>&1
} } elseif($tool -eq "cs2pr") {
if($tool -eq "cs2pr") {
(Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr (Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr
} elseif($tool -eq "composer") {
composer -q global config process-timeout 0
} }
if (((Get-ChildItem -Path $php_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) { if (((Get-ChildItem -Path $php_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
Add-Log $tick $tool "Added" Add-Log $tick $tool "Added"
@ -202,7 +200,12 @@ if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version
$installed = Get-Php -Path $php_dir $installed = Get-Php -Path $php_dir
Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir
Enable-PhpExtension -Extension openssl, curl, opcache -Path $php_dir if($version -lt "5.5") {
Add-Extension openssl >$null 2>&1
Add-Extension curl >$null 2>&1
} else {
Enable-PhpExtension -Extension openssl, curl, opcache -Path $php_dir
}
Update-PhpCAInfo -Path $php_dir -Source CurrentUser Update-PhpCAInfo -Path $php_dir -Source CurrentUser
if ($version -eq 'master') { if ($version -eq 'master') {
if($installed.ThreadSafe) { if($installed.ThreadSafe) {