Skip to content

Commit

Permalink
Correct PSR extension, PHP 8 and XDebug fixes (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxGoryunov authored Jan 29, 2022
1 parent 125d831 commit 89414ea
Showing 1 changed file with 54 additions and 4 deletions.
58 changes: 54 additions & 4 deletions php-appveyor.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function InstallPeclExtension {
# https://windows.php.net/downloads/pecl/releases/psr/1.0.1/php_psr-1.0.1-7.4-ts-vc15-x86.zip
$PackageVersion = $Version
$CompatiblePhpVersion = $PhpVersion
if ([System.Convert]::ToDecimal($PhpVersion) -ge 8.0) {
if (([System.Convert]::ToDecimal($PhpVersion) -ge 8.0) -and ($Name -Match "psr")) {
$PackageVersion = "1.0.1"
$CompatiblePhpVersion = "7.4"
$VC = "15"
Expand All @@ -171,8 +171,14 @@ function InstallPeclExtension {
$TS = "ts"
}

$RemoteUrl = "${BaseUri}/${LocalPart}-${TS}-vc${VC}-${Platform}.zip"
$DestinationPath = "C:\Downloads\${LocalPart}-${TS}-vc${VC}-${Platform}.zip"
# A workaround for php 8.0
$CompilerVersion = "vc${VC}"
if ([System.Convert]::ToDecimal($PhpVersion) -ge 8.0) {
$CompilerVersion = "vs${VC}"
}

$RemoteUrl = "${BaseUri}/${LocalPart}-${TS}-${CompilerVersion}-${Platform}.zip"
$DestinationPath = "C:\Downloads\${LocalPart}-${TS}-${CompilerVersion}-${Platform}.zip"

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

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

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

function EnableZendExtension {
param (
[Parameter(Mandatory=$true)] [System.String] $Name,
[Parameter(Mandatory=$false)] [System.String] $PhpInstallPath = 'C:\php',
[Parameter(Mandatory=$false)] [System.String] $ExtPath = 'C:\php\ext',
[Parameter(Mandatory=$false)] [System.String] $PrintableName = ''
)

$FullyQualifiedExtensionPath = "${ExtPath}\php_${Name}.dll"

$IniFile = "${PhpInstallPath}\php.ini"
$PhpExe = "${PhpInstallPath}\php.exe"

if (-not (Test-Path $IniFile)) {
throw "Unable to locate ${IniFile}"
}

if (-not (Test-Path "${ExtPath}")) {
throw "Unable to locate ${ExtPath} direcory"
}

Write-Debug "Add `"zend_extension = ${FullyQualifiedExtensionPath}`" to the ${IniFile}"
Write-Output "zend_extension = ${FullyQualifiedExtensionPath}" | Out-File -Encoding "ASCII" -Append $IniFile

if (Test-Path -Path "${PhpExe}") {
if ($PrintableName) {
Write-Debug "Minimal load test using command: ${PhpExe} --ri `"${PrintableName}`""
$Result = (& "${PhpExe}" --ri "${PrintableName}")
} else {
Write-Debug "Minimal load test using command: ${PhpExe} --ri ${Name}"
$Result = (& "${PhpExe}" --ri "${Name}")
}

$ExitCode = $LASTEXITCODE
if ($ExitCode -ne 0) {
throw "An error occurred while enabling ${Name} at ${IniFile}. ${Result}"
}
}
}

function TuneUpPhp {
param (
[Parameter(Mandatory=$false)] [System.String] $MemoryLimit = '256M',
Expand Down

0 comments on commit 89414ea

Please sign in to comment.