Skip to content

Commit c3070fb

Browse files
authored
Merge pull request #86 from mlocati/ext-additional-files-custom-path
Let users specify where additional DLL files should be saved
2 parents 2a70248 + b93c7dc commit c3070fb

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

PhpManager/public/Install-PhpExtension.ps1

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
[ValidateNotNull()]
5151
[ValidateLength(1, [int]::MaxValue)]
5252
[string] $Path,
53+
[Parameter(Mandatory = $false, Position = 4, HelpMessage = 'The path where additional files (DLL, ...) will be installed; if omitted we''ll use the directory where PHP resides')]
54+
[ValidateNotNull()]
55+
[ValidateLength(1, [int]::MaxValue)]
56+
[string] $AdditionalFilesPath,
5357
[switch] $DontEnable,
5458
[switch] $NoDependencies
5559
)
@@ -68,6 +72,11 @@
6872
if (-Not(Test-Path -LiteralPath $phpVersion.ExtensionsPath -PathType Container)) {
6973
throw "The PHP extension directory ""$($phpVersion.ExtensionsPath)"" configured in your php.ini does not exist. You may need to create it, or fix the extension_dir setting in the php.ini file."
7074
}
75+
if ($null -eq $AdditionalFilesPath -or $AdditionalFilesPath -eq '') {
76+
$AdditionalFilesPath = $phpVersion.ActualFolder
77+
} elseif (-Not(Test-Path -LiteralPath $AdditionalFilesPath -PathType Container)) {
78+
throw "The directory ""$AdditionalFilesPath"" where additional files should be saved does not exist."
79+
}
7180
if ($null -eq $Version) {
7281
$Version = ''
7382
}
@@ -219,7 +228,7 @@
219228
Write-Debug -Message "Failed to reset the ACL for $($oldExtension.Filename): $($_.Exception.Message)"
220229
}
221230
foreach ($additionalFile in $additionalFiles) {
222-
$additionalFileDestination = Join-Path -Path $phpVersion.ActualFolder -ChildPath $(Split-Path -Path $additionalFile -Leaf)
231+
$additionalFileDestination = Join-Path -Path $AdditionalFilesPath -ChildPath $(Split-Path -Path $additionalFile -Leaf)
223232
Copy-Item -LiteralPath $additionalFile -Destination $additionalFileDestination -Force
224233
try {
225234
Reset-Acl -Path $additionalFileDestination
@@ -234,7 +243,7 @@
234243
else {
235244
Write-Verbose ("Installing new extension '{0}' version {1}" -f $newExtension.Name, $newExtension.Version)
236245
if (-not($NoDependencies)) {
237-
Install-PhpExtensionPrerequisite -Extension $newExtension.Handle -PhpPath $phpVersion.ActualFolder
246+
Install-PhpExtensionPrerequisite -Extension $newExtension.Handle -InstallPath $AdditionalFilesPath -PhpPath $phpVersion.ActualFolder
238247
}
239248
if ($null -eq $finalDllName) {
240249
$newExtensionFilename = [System.IO.Path]::Combine($phpVersion.ExtensionsPath, [System.IO.Path]::GetFileName($dllPath))
@@ -249,7 +258,7 @@
249258
Write-Debug -Message "Failed to reset the ACL for $($newExtensionFilename): $($_.Exception.Message)"
250259
}
251260
foreach ($additionalFile in $additionalFiles) {
252-
$additionalFileDestination = Join-Path -Path $phpVersion.ActualFolder -ChildPath $(Split-Path -Path $additionalFile -Leaf)
261+
$additionalFileDestination = Join-Path -Path $AdditionalFilesPath -ChildPath $(Split-Path -Path $additionalFile -Leaf)
253262
Copy-Item -LiteralPath $additionalFile -Destination $additionalFileDestination -Force
254263
try {
255264
Reset-Acl -Path $additionalFileDestination

0 commit comments

Comments
 (0)