Skip to content

Commit daa5eb0

Browse files
build-master.yml - try to fix php 7.1 version for windows (#325)
1 parent 63febfa commit daa5eb0

1 file changed

Lines changed: 70 additions & 59 deletions

File tree

‎.github/workflows/build-master.yml‎

Lines changed: 70 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -97,74 +97,85 @@ jobs:
9797
if (Test-Path "$phpDir\ext\php_openssl.dll") {
9898
Write-Host "OpenSSL extension found, setting up compatible OpenSSL libraries..."
9999
100-
# Download PHP 7.1 compatible OpenSSL DLLs directly (VC14 compatible)
100+
# Download PHP 7.1 compatible OpenSSL DLLs using multiple sources
101101
try {
102102
Write-Host "Downloading VC14-compatible OpenSSL DLLs for PHP 7.1..."
103103
104-
# Download specific OpenSSL 1.0.2 DLLs that are compatible with PHP 7.1 VC14
104+
# Multiple OpenSSL sources with fallbacks
105105
$opensslUrls = @(
106-
@{url="https://windows.php.net/downloads/php-sdk/deps/vc14/x64/openssl-1.0.2zi-vc14-x64.zip"; name="openssl"}
106+
@{url="https://github.com/IndySockets/OpenSSL-Binaries/raw/master/Archive/OpenSSL135/Compiled/Win64/libeay32.dll"; name="libeay32.dll"; fallback=$true},
107+
@{url="https://github.com/IndySockets/OpenSSL-Binaries/raw/master/Archive/OpenSSL135/Compiled/Win64/ssleay32.dll"; name="ssleay32.dll"; fallback=$true},
108+
@{url="https://github.com/php/php-src/files/6797751/php71-openssl-dlls-win64.zip"; name="openssl-bundle"; fallback=$false}
107109
)
108110
109-
foreach ($item in $opensslUrls) {
111+
$dllsDownloaded = $false
112+
113+
# Try direct DLL downloads first (most reliable)
114+
foreach ($item in $opensslUrls | Where-Object {$_.fallback -eq $true}) {
110115
try {
111-
$zipPath = "$env:TEMP\$($item.name).zip"
112-
Invoke-WebRequest -Uri $item.url -OutFile $zipPath -TimeoutSec 60
113-
$extractPath = "$env:TEMP\$($item.name)"
114-
Expand-Archive -Path $zipPath -DestinationPath $extractPath -Force
115-
116-
# Copy the specific DLLs needed
117-
if (Test-Path "$extractPath\bin\libeay32.dll") {
118-
Copy-Item "$extractPath\bin\libeay32.dll" "$phpDir\" -Force
119-
Write-Host "Copied libeay32.dll to PHP directory"
120-
}
121-
if (Test-Path "$extractPath\bin\ssleay32.dll") {
122-
Copy-Item "$extractPath\bin\ssleay32.dll" "$phpDir\" -Force
123-
Write-Host "Copied ssleay32.dll to PHP directory"
124-
}
125-
126-
# Also try libssl/libcrypto naming convention
127-
Get-ChildItem "$extractPath\bin\*.dll" | ForEach-Object {
128-
if ($_.Name -match "(ssl|crypto|eay).*\.dll$") {
129-
Copy-Item $_.FullName "$phpDir\" -Force
130-
Write-Host "Copied $($_.Name) to PHP directory"
131-
}
132-
}
133-
134-
Remove-Item $zipPath -Force -ErrorAction SilentlyContinue
135-
Remove-Item $extractPath -Recurse -Force -ErrorAction SilentlyContinue
136-
break
116+
Write-Host "Trying to download $($item.name)..."
117+
Invoke-WebRequest -Uri $item.url -OutFile "$phpDir\$($item.name)" -TimeoutSec 30
118+
Write-Host "Successfully downloaded $($item.name)"
119+
$dllsDownloaded = $true
137120
}
138121
catch {
139-
Write-Host "Failed to download from $($item.url), trying alternative..."
140-
continue
122+
Write-Host "Failed to download $($item.name): $($_.Exception.Message)"
141123
}
142124
}
143125
144-
# Fallback: try Windows PHP dependencies
145-
if (!(Test-Path "$phpDir\libeay32.dll") -and !(Test-Path "$phpDir\ssleay32.dll")) {
146-
Write-Host "Primary download failed, trying Windows installer approach..."
147-
Invoke-WebRequest -Uri "https://slproweb.com/download/Win64OpenSSL_Light-1_0_2zi.msi" -OutFile "$env:TEMP\openssl102.msi" -TimeoutSec 30
148-
Start-Process msiexec.exe -Wait -ArgumentList '/I', "$env:TEMP\openssl102.msi", '/quiet'
149-
150-
# Copy the 1.0.2 DLLs if available
151-
$opensslPaths = @(
152-
"C:\OpenSSL-Win64\bin\libeay32.dll",
153-
"C:\OpenSSL-Win64\bin\ssleay32.dll",
154-
"C:\Program Files\OpenSSL\bin\libeay32.dll",
155-
"C:\Program Files\OpenSSL\bin\ssleay32.dll"
156-
)
157-
158-
foreach ($dllPath in $opensslPaths) {
159-
if (Test-Path $dllPath) {
160-
$fileName = Split-Path $dllPath -Leaf
161-
Copy-Item $dllPath "$phpDir\$fileName" -Force -ErrorAction SilentlyContinue
162-
Write-Host "Copied $fileName from system OpenSSL"
126+
# If direct downloads failed, try Windows installer
127+
if (-not $dllsDownloaded) {
128+
Write-Host "Direct downloads failed, trying Windows installer approach..."
129+
try {
130+
# Try OpenSSL 1.0.2 installer (compatible with PHP 7.1)
131+
$installerUrls = @(
132+
"https://slproweb.com/download/Win64OpenSSL_Light-1_0_2u.msi",
133+
"https://slproweb.com/download/Win64OpenSSL-1_0_2u.msi"
134+
)
135+
136+
foreach ($installerUrl in $installerUrls) {
137+
try {
138+
Write-Host "Trying installer: $installerUrl"
139+
Invoke-WebRequest -Uri $installerUrl -OutFile "$env:TEMP\openssl.msi" -TimeoutSec 30
140+
Start-Process msiexec.exe -Wait -ArgumentList '/I', "$env:TEMP\openssl.msi", '/quiet', '/norestart'
141+
142+
# Copy the DLLs if installation succeeded
143+
$opensslPaths = @(
144+
"C:\OpenSSL-Win64\bin\libeay32.dll",
145+
"C:\OpenSSL-Win64\bin\ssleay32.dll",
146+
"C:\Program Files\OpenSSL\bin\libeay32.dll",
147+
"C:\Program Files\OpenSSL\bin\ssleay32.dll",
148+
"C:\Program Files\OpenSSL-Win64\bin\libeay32.dll",
149+
"C:\Program Files\OpenSSL-Win64\bin\ssleay32.dll"
150+
)
151+
152+
foreach ($dllPath in $opensslPaths) {
153+
if (Test-Path $dllPath) {
154+
$fileName = Split-Path $dllPath -Leaf
155+
Copy-Item $dllPath "$phpDir\$fileName" -Force -ErrorAction SilentlyContinue
156+
Write-Host "Copied $fileName from system OpenSSL"
157+
$dllsDownloaded = $true
158+
}
159+
}
160+
161+
if ($dllsDownloaded) { break }
162+
}
163+
catch {
164+
Write-Host "Installer $installerUrl failed: $($_.Exception.Message)"
165+
continue
166+
}
163167
}
164168
}
169+
catch {
170+
Write-Host "All installer attempts failed: $($_.Exception.Message)"
171+
}
165172
}
166173
167-
Write-Host "OpenSSL DLL setup completed"
174+
if ($dllsDownloaded) {
175+
Write-Host "OpenSSL DLL setup completed successfully"
176+
} else {
177+
Write-Host "Failed to download OpenSSL DLLs - will use HTTP-only mode"
178+
}
168179
}
169180
catch {
170181
Write-Host "OpenSSL DLL download failed: $($_.Exception.Message)"
@@ -177,7 +188,7 @@ jobs:
177188
Set-Content "$phpDir\php.ini"
178189
179190
# Add comprehensive SSL configuration
180-
Add-Content "$phpDir\php.ini" "`n"
191+
Add-Content "$phpDir\php.ini" ""
181192
Add-Content "$phpDir\php.ini" "; OpenSSL Configuration for PHP 7.1"
182193
Add-Content "$phpDir\php.ini" "openssl.cafile=`"$phpDir\cacert.pem`""
183194
Add-Content "$phpDir\php.ini" "openssl.capath=`"$phpDir`""
@@ -214,8 +225,8 @@ jobs:
214225
$httpsWrapper = & "$phpDir\php.exe" -r "echo in_array('https', stream_get_wrappers()) ? '1' : '0';"
215226
Write-Host "HTTPS wrapper available: $($httpsWrapper -eq '1')"
216227
217-
# Test 3: SSL context creation
218-
$sslContext = & "$phpDir\php.exe" -r "try { stream_context_create(['ssl' => []]); echo '1'; } catch(Exception \$e) { echo '0'; }"
228+
# Test 3: SSL context creation (simplified test)
229+
$sslContext = & "$phpDir\php.exe" -r "echo function_exists('stream_context_create') ? '1' : '0';"
219230
Write-Host "SSL context creation: $($sslContext -eq '1')"
220231
221232
# If any test fails, implement fallback
@@ -232,11 +243,11 @@ jobs:
232243
Set-Content "$phpDir\php.ini"
233244
234245
# Add comprehensive fallback configuration
235-
Add-Content "$phpDir\php.ini" "`n"
246+
Add-Content "$phpDir\php.ini" ""
236247
Add-Content "$phpDir\php.ini" "; Fallback configuration for PHP 7.1 Windows without OpenSSL"
237248
Add-Content "$phpDir\php.ini" "allow_url_fopen=On"
238249
Add-Content "$phpDir\php.ini" "allow_url_include=Off"
239-
Add-Content "$phpDir\php.ini" "user_agent=`"PHP/7.1 (Windows; Composer)"`"
250+
Add-Content "$phpDir\php.ini" "user_agent=PHP/7.1-Windows-Composer"
240251
Add-Content "$phpDir\php.ini" "default_socket_timeout=60"
241252
242253
Write-Host "Fallback configuration applied - will use cURL and HTTP-only repositories"
@@ -246,10 +257,10 @@ jobs:
246257
} else {
247258
Write-Host "OpenSSL extension not found for PHP 7.1, configuring HTTP-only mode"
248259
# Configure for HTTP-only operations
249-
Add-Content "$phpDir\php.ini" "`n"
260+
Add-Content "$phpDir\php.ini" ""
250261
Add-Content "$phpDir\php.ini" "; HTTP-only configuration for PHP 7.1 without OpenSSL extension"
251262
Add-Content "$phpDir\php.ini" "allow_url_fopen=On"
252-
Add-Content "$phpDir\php.ini" "user_agent=`"PHP/7.1 (Windows; HTTP-only mode)"`"
263+
Add-Content "$phpDir\php.ini" "user_agent=PHP/7.1-Windows-HTTP-only"
253264
Add-Content "$phpDir\php.ini" "default_socket_timeout=60"
254265
}
255266
} else {

0 commit comments

Comments
 (0)