Skip to content

Commit 89414ea

Browse files
authored
Correct PSR extension, PHP 8 and XDebug fixes (#16)
1 parent 125d831 commit 89414ea

File tree

1 file changed

+54
-4
lines changed

1 file changed

+54
-4
lines changed

php-appveyor.psm1

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function InstallPeclExtension {
156156
# https://windows.php.net/downloads/pecl/releases/psr/1.0.1/php_psr-1.0.1-7.4-ts-vc15-x86.zip
157157
$PackageVersion = $Version
158158
$CompatiblePhpVersion = $PhpVersion
159-
if ([System.Convert]::ToDecimal($PhpVersion) -ge 8.0) {
159+
if (([System.Convert]::ToDecimal($PhpVersion) -ge 8.0) -and ($Name -Match "psr")) {
160160
$PackageVersion = "1.0.1"
161161
$CompatiblePhpVersion = "7.4"
162162
$VC = "15"
@@ -171,8 +171,14 @@ function InstallPeclExtension {
171171
$TS = "ts"
172172
}
173173

174-
$RemoteUrl = "${BaseUri}/${LocalPart}-${TS}-vc${VC}-${Platform}.zip"
175-
$DestinationPath = "C:\Downloads\${LocalPart}-${TS}-vc${VC}-${Platform}.zip"
174+
# A workaround for php 8.0
175+
$CompilerVersion = "vc${VC}"
176+
if ([System.Convert]::ToDecimal($PhpVersion) -ge 8.0) {
177+
$CompilerVersion = "vs${VC}"
178+
}
179+
180+
$RemoteUrl = "${BaseUri}/${LocalPart}-${TS}-${CompilerVersion}-${Platform}.zip"
181+
$DestinationPath = "C:\Downloads\${LocalPart}-${TS}-${CompilerVersion}-${Platform}.zip"
176182

177183
if (-not (Test-Path "${InstallPath}\php_${Name}.dll")) {
178184
if (-not (Test-Path $DestinationPath)) {
@@ -240,7 +246,11 @@ function InstallComposer {
240246
$ComposerPhar = "${InstallPath}\composer.phar"
241247

242248
if (-not (Test-Path -Path $ComposerPhar)) {
243-
DownloadFile "https://getcomposer.org/composer.phar" "${ComposerPhar}"
249+
EnablePhpExtension -Name openssl
250+
Invoke-Expression "${PhpInstallPath}\php.exe -r `"copy('https://getcomposer.org/installer', 'composer-setup.php');`""
251+
Invoke-Expression "${PhpInstallPath}\php.exe composer-setup.php"
252+
Invoke-Expression "${PhpInstallPath}\php.exe -r `"unlink('composer-setup.php');`""
253+
#DownloadFile "https://getcomposer.org/composer.phar" "${ComposerPhar}"
244254

245255
Write-Output '@echo off' | Out-File -Encoding "ASCII" $ComposerBatch
246256
Write-Output "${PhpInstallPath}\php.exe `"${ComposerPhar}`" %*" | Out-File -Encoding "ASCII" -Append $ComposerBatch
@@ -310,6 +320,46 @@ function EnablePhpExtension {
310320
}
311321
}
312322

323+
function EnableZendExtension {
324+
param (
325+
[Parameter(Mandatory=$true)] [System.String] $Name,
326+
[Parameter(Mandatory=$false)] [System.String] $PhpInstallPath = 'C:\php',
327+
[Parameter(Mandatory=$false)] [System.String] $ExtPath = 'C:\php\ext',
328+
[Parameter(Mandatory=$false)] [System.String] $PrintableName = ''
329+
)
330+
331+
$FullyQualifiedExtensionPath = "${ExtPath}\php_${Name}.dll"
332+
333+
$IniFile = "${PhpInstallPath}\php.ini"
334+
$PhpExe = "${PhpInstallPath}\php.exe"
335+
336+
if (-not (Test-Path $IniFile)) {
337+
throw "Unable to locate ${IniFile}"
338+
}
339+
340+
if (-not (Test-Path "${ExtPath}")) {
341+
throw "Unable to locate ${ExtPath} direcory"
342+
}
343+
344+
Write-Debug "Add `"zend_extension = ${FullyQualifiedExtensionPath}`" to the ${IniFile}"
345+
Write-Output "zend_extension = ${FullyQualifiedExtensionPath}" | Out-File -Encoding "ASCII" -Append $IniFile
346+
347+
if (Test-Path -Path "${PhpExe}") {
348+
if ($PrintableName) {
349+
Write-Debug "Minimal load test using command: ${PhpExe} --ri `"${PrintableName}`""
350+
$Result = (& "${PhpExe}" --ri "${PrintableName}")
351+
} else {
352+
Write-Debug "Minimal load test using command: ${PhpExe} --ri ${Name}"
353+
$Result = (& "${PhpExe}" --ri "${Name}")
354+
}
355+
356+
$ExitCode = $LASTEXITCODE
357+
if ($ExitCode -ne 0) {
358+
throw "An error occurred while enabling ${Name} at ${IniFile}. ${Result}"
359+
}
360+
}
361+
}
362+
313363
function TuneUpPhp {
314364
param (
315365
[Parameter(Mandatory=$false)] [System.String] $MemoryLimit = '256M',

0 commit comments

Comments
 (0)