Install cached Windows PHP builds directly

This commit is contained in:
Shivam Mathur
2026-09-03 13:11:48 +05:30
parent c482204203
commit 4de6f6f4a5
+15 -6
View File
@@ -278,13 +278,19 @@ Function Add-PhpConfig {
Get-Content -Path $ini_files | Add-Content -Path $php_dir\php.ini Get-Content -Path $ini_files | Add-Content -Path $php_dir\php.ini
} }
# Function to get PHP from GitHub releases cache # Function to install PHP directly from the GitHub releases cache.
Function Set-PhpCache { Function Install-PhpFromCache {
try {
$asset = Get-PhpReleaseAsset -Type php $asset = Get-PhpReleaseAsset -Type php
Get-File -Url $php_builder/releases/download/php$version/$asset -FallbackUrl $php_windows/releases/archives/$asset -OutFile $php_dir\$asset $url = "$php_builder/releases/download/php$version/$asset"
Get-File -Url $url -FallbackUrl $php_windows/releases/archives/$asset -OutFile $php_dir\$asset
Set-PhpDownloadCache -Path $php_dir CurrentUser Set-PhpDownloadCache -Path $php_dir CurrentUser
} catch { } $php_version = Get-PhpVersionFromUrl -Url $url -ReleaseState Release
Install-PhpFromUrl -Url $url -Path $php_dir -PhpVersion $php_version -InstallVCRedist $true
$ini_path = "$php_dir\php.ini"
Copy-Item -Path $php_dir\php.ini-production -Destination $ini_path -Force
Set-PhpIniKey -Key date.timezone -Value UTC -Path $ini_path
Set-PhpIniKey -Key default_charset -Value UTF-8 -Path $ini_path
Set-PhpIniKey -Key extension_dir -Value $ext_dir -Path $ini_path
} }
# Function to add debug symbols to PHP. # Function to add debug symbols to PHP.
@@ -415,9 +421,12 @@ if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version
if ($version -match $nightly_versions) { if ($version -match $nightly_versions) {
$extra_version = Install-PhpNightly $extra_version = Install-PhpNightly
} else { } else {
Set-PhpCache try {
Install-PhpFromCache > $null 2>&1
} catch {
Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni production -Force > $null 2>&1 Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni production -Force > $null 2>&1
} }
}
Add-PhpConfig Add-PhpConfig
} catch { } } catch { }
} else { } else {