mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Add support to install extensions from shivammathur/php-extensions-windows
This commit is contained in:
parent
5afd8a1842
commit
e51e662ef0
2
src/configs/windows_extensions
Normal file
2
src/configs/windows_extensions
Normal file
@ -0,0 +1,2 @@
|
||||
xdebug
|
||||
pcov
|
@ -6,8 +6,9 @@ Function Set-ExtensionPrerequisites
|
||||
[ValidateNotNull()]
|
||||
[ValidateLength(1, [int]::MaxValue)]
|
||||
[string]
|
||||
$deps_dir
|
||||
$extension
|
||||
)
|
||||
$deps_dir = "$ext_dir\$extension-vc$($installed.VCVersion)-$arch"
|
||||
$deps = Get-ChildItem -Recurse -Path $deps_dir
|
||||
if ($deps.Count -ne 0) {
|
||||
# Symlink dependencies instead of adding the directory to PATH ...
|
||||
@ -20,6 +21,41 @@ Function Set-ExtensionPrerequisites
|
||||
}
|
||||
}
|
||||
|
||||
# Function to enable extension.
|
||||
Function Enable-Extension() {
|
||||
Param (
|
||||
[Parameter(Position = 0, Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
[ValidateLength(1, [int]::MaxValue)]
|
||||
[string]
|
||||
$extension
|
||||
)
|
||||
Enable-ExtensionDependencies $extension
|
||||
Enable-PhpExtension -Extension $extension -Path $php_dir
|
||||
Set-ExtensionPrerequisites $extension
|
||||
Add-Log $tick $extension "Enabled"
|
||||
}
|
||||
|
||||
# Function to add custom built PHP extension for nightly builds.
|
||||
Function Add-NightlyExtension {
|
||||
Param (
|
||||
[Parameter(Position = 0, Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
[ValidateLength(1, [int]::MaxValue)]
|
||||
[string]
|
||||
$extension
|
||||
)
|
||||
if($ts) { $ts_part = 'ts' } else { $ts_part = 'nts' }
|
||||
$repo = "$github/shivammathur/php-extensions-windows"
|
||||
$url = "$repo/releases/download/builds/php$version`_$ts_part`_$arch`_$extension.dll"
|
||||
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile "$ext_dir\php_$extension.dll"
|
||||
if(Test-Path "$ext_dir\php_$extension.dll") {
|
||||
Enable-Extension $extension > $null
|
||||
} else {
|
||||
throw "Failed to download the $extension"
|
||||
}
|
||||
}
|
||||
|
||||
# Function to add PHP extensions.
|
||||
Function Add-Extension {
|
||||
Param (
|
||||
@ -52,31 +88,33 @@ Function Add-Extension {
|
||||
Add-Log $tick $extension "Enabled"
|
||||
}
|
||||
default {
|
||||
Enable-ExtensionDependencies $extension
|
||||
Enable-PhpExtension -Extension $extension_info.Handle -Path $php_dir
|
||||
Set-ExtensionPrerequisites $deps_dir
|
||||
Add-Log $tick $extension "Enabled"
|
||||
Enable-Extension $extension_info.Handle
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(($version -match $nightly_versions) -and (Select-String -Path $src\configs\windows_extensions -Pattern $extension -SimpleMatch -Quiet)) {
|
||||
Add-NightlyExtension $extension
|
||||
} else {
|
||||
# Patch till PHP 8.2 DLLs are released as stable.
|
||||
$minimumStability = $stability
|
||||
if($version -eq '8.2' -and $stability -eq 'stable') {
|
||||
if ($version -eq '8.2' -and $stability -eq 'stable')
|
||||
{
|
||||
$minimumStability = 'snapshot'
|
||||
}
|
||||
|
||||
$params = @{ Extension = $extension; MinimumStability = $minimumStability; MaximumStability = $stability; Path = $php_dir; AdditionalFilesPath = $deps_dir; NoDependencies = $true }
|
||||
if($extension_version -ne '') {
|
||||
if ($extension_version -ne '')
|
||||
{
|
||||
$params["Version"] = $extension_version
|
||||
}
|
||||
Install-PhpExtension @params
|
||||
Set-ExtensionPrerequisites $deps_dir
|
||||
Set-ExtensionPrerequisites $extension
|
||||
}
|
||||
Add-Log $tick $extension "Installed and enabled"
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
|
||||
} catch {
|
||||
Add-Log $cross $extension "Could not install $extension on PHP $( $installed.FullVersion )"
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user