mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Use AdditionalFilesPath parameter in Install-PhpExtension
AdditionalFilesPath allows to specify a directory inside extension directory (which can be cached) for installing dependencies which are in the same archive as the extension Fix dependency directory name to correctly use VCVersion in win32.ps1 Fix exception in phalcon4 setup on Windows.
This commit is contained in:
parent
4d3cfaa653
commit
ca319bd10e
@ -1,7 +1,7 @@
|
|||||||
# Function to install phalcon
|
# Function to install phalcon
|
||||||
Function Add-PhalconHelper() {
|
Function Add-PhalconHelper() {
|
||||||
if ($extension_version -eq '4') {
|
if ($extension_version -eq '4') {
|
||||||
Install-Phpextension phalcon -MinimumStability stable -Path $php_dir
|
Install-Phpextension -Extension phalcon -MinimumStability stable -Path $php_dir
|
||||||
} else {
|
} else {
|
||||||
$domain = 'https://github.com'
|
$domain = 'https://github.com'
|
||||||
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
|
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
|
||||||
@ -30,7 +30,7 @@ Function Add-Phalcon() {
|
|||||||
if (Test-Path $ext_dir\php_psr.dll) {
|
if (Test-Path $ext_dir\php_psr.dll) {
|
||||||
Enable-PhpExtension -Extension psr -Path $php_dir
|
Enable-PhpExtension -Extension psr -Path $php_dir
|
||||||
} else {
|
} else {
|
||||||
Install-Phpextension psr -MinimumStability stable -Path $php_dir
|
Install-Phpextension -Extension psr -MinimumStability stable -Path $php_dir
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,6 @@ Function Add-Phalcon() {
|
|||||||
}
|
}
|
||||||
Add-Log $tick $extension $status
|
Add-Log $tick $extension $status
|
||||||
} catch [Exception] {
|
} catch [Exception] {
|
||||||
Write-Output $_.Exception|format-list -force
|
|
||||||
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
|
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ param (
|
|||||||
[ValidateNotNull()]
|
[ValidateNotNull()]
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
[string]
|
[string]
|
||||||
$version = '7.4',
|
$version = '8.0',
|
||||||
[Parameter(Position = 1, Mandatory = $true)]
|
[Parameter(Position = 1, Mandatory = $true)]
|
||||||
[ValidateNotNull()]
|
[ValidateNotNull()]
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
@ -119,7 +119,32 @@ Function Install-PSPackage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Add-ExtensionPrerequisites{
|
# Function to link dependencies to PHP directory.
|
||||||
|
Function Set-ExtensionPrerequisites
|
||||||
|
{
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$deps_dir
|
||||||
|
)
|
||||||
|
$deps = Get-ChildItem -Recurse -Path $deps_dir
|
||||||
|
if ($deps.Count -ne 0) {
|
||||||
|
# Symlink dependencies instead of adding the directory to PATH ...
|
||||||
|
# as other actions change the PATH thus breaking extensions.
|
||||||
|
$deps | ForEach-Object {
|
||||||
|
New-Item -Itemtype SymbolicLink -Path $php_dir -Name $_.Name -Target $_.FullName -Force > $null 2>&1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Remove-Item $deps_dir -Recurse -Force
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to get extension pre-requisites.
|
||||||
|
# https://windows.php.net/downloads/pecl/deps
|
||||||
|
# Currently only imagick is supported using this Cmdlet.
|
||||||
|
Function Get-ExtensionPrerequisites{
|
||||||
Param (
|
Param (
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
[ValidateNotNull()]
|
[ValidateNotNull()]
|
||||||
@ -127,17 +152,13 @@ Function Add-ExtensionPrerequisites{
|
|||||||
[string]
|
[string]
|
||||||
$extension
|
$extension
|
||||||
)
|
)
|
||||||
$deps_dir = "$ext_dir\$extension-vc$installed.VCVersion-$arch"
|
$deps_dir = "$ext_dir\$extension-vc$($installed.VCVersion)-$arch"
|
||||||
$extensions_with_dependencies = ('imagick')
|
$extensions_with_dependencies = ('imagick')
|
||||||
|
New-Item $deps_dir -Type Directory 2>&1 | Out-Null
|
||||||
if($extensions_with_dependencies.Contains($extension)) {
|
if($extensions_with_dependencies.Contains($extension)) {
|
||||||
if(-not(Test-Path $deps_dir)) {
|
Install-PhpExtensionPrerequisite -Extension $extension -InstallPath $deps_dir -PhpPath $php_dir
|
||||||
New-Item $deps_dir -Type Directory 2>&1 | Out-Null
|
|
||||||
Install-PhpExtensionPrerequisite -Extension $extension -InstallPath $deps_dir -PhpPath $php_dir
|
|
||||||
}
|
|
||||||
Get-ChildItem -Recurse -Path $deps_dir | ForEach-Object {
|
|
||||||
New-Item -Itemtype SymbolicLink -Path $php_dir -Name $_.Name -Target $_.FullName -Force >$null 2>&1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return $deps_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to add PHP extensions.
|
# Function to add PHP extensions.
|
||||||
@ -170,20 +191,21 @@ Function Add-Extension {
|
|||||||
Add-Log $tick $extension "Enabled"
|
Add-Log $tick $extension "Enabled"
|
||||||
}
|
}
|
||||||
default {
|
default {
|
||||||
Add-ExtensionPrerequisites $extension
|
$deps_dir = Get-ExtensionPrerequisites $extension
|
||||||
Enable-PhpExtension -Extension $extension_info.Handle -Path $php_dir
|
Enable-PhpExtension -Extension $extension_info.Handle -Path $php_dir
|
||||||
|
Set-ExtensionPrerequisites $deps_dir
|
||||||
Add-Log $tick $extension "Enabled"
|
Add-Log $tick $extension "Enabled"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Add-ExtensionPrerequisites $extension
|
$deps_dir = Get-ExtensionPrerequisites $extension
|
||||||
|
$params = @{ Extension = $extension; MinimumStability = $stability; MaximumStability = $stability; Path = $php_dir; AdditionalFilesPath = $deps_dir; NoDependencies = $true }
|
||||||
if($extension_version -ne '') {
|
if($extension_version -ne '') {
|
||||||
Install-PhpExtension -Extension $extension -Version $extension_version -MinimumStability $stability -MaximumStability $stability -Path $php_dir -NoDependencies
|
$params["Version"] = $extension_version
|
||||||
} else {
|
|
||||||
Install-PhpExtension -Extension $extension -MinimumStability $stability -MaximumStability $stability -Path $php_dir -NoDependencies
|
|
||||||
}
|
}
|
||||||
|
Install-PhpExtension @params
|
||||||
|
Set-ExtensionPrerequisites $deps_dir
|
||||||
Add-Log $tick $extension "Installed and enabled"
|
Add-Log $tick $extension "Installed and enabled"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,6 +238,7 @@ Function Remove-Extension() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to configure composer.
|
||||||
Function Edit-ComposerConfig() {
|
Function Edit-ComposerConfig() {
|
||||||
Param(
|
Param(
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
Loading…
Reference in New Issue
Block a user