setup-php/src/scripts/ext/oci.ps1

59 lines
2.1 KiB
PowerShell
Raw Normal View History

2020-07-26 17:18:19 +07:00
# Function to log license information.
Function Add-LicenseLog() {
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $extension "Click to read the $extension related license information"
printf "Oracle Instant Client package is required for %s extension.\n" $extension
printf "It is provided under the Oracle Technology Network Development and Distribution License.\n"
printf "Refer to: \033[35;1m%s \033[0m\n" "https://www.oracle.com/downloads/licenses/instant-client-lic.html"
Write-Output "::endgroup::"
}
2020-07-26 17:18:19 +07:00
# Function to get instantclinet.
Function Add-InstantClient() {
if (-not(Test-Path $php_dir\oci.dll)) {
$suffix = 'windows'
2020-07-26 17:18:19 +07:00
if ($arch -eq 'x86') {
$suffix = 'nt'
}
Invoke-WebRequest -UseBasicParsing -Uri https://download.oracle.com/otn_software/nt/instantclient/instantclient-basiclite-$suffix.zip -OutFile $php_dir\instantclient.zip
Expand-Archive -Path $php_dir\instantclient.zip -DestinationPath $php_dir -Force
Copy-Item $php_dir\instantclient*\* $php_dir
2020-07-15 11:15:40 +07:00
}
2020-07-26 17:18:19 +07:00
}
# Function to install oci8 and pdo_oci.
2020-08-06 17:03:58 +07:00
Function Add-Oci() {
2020-07-26 17:18:19 +07:00
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[ValidateSet('oci8', 'pdo_oci')]
[string]
$extension
)
try {
$status = 'Enabled'
Add-InstantClient
if ($extension -eq "pdo_oci") {
Enable-PhpExtension pdo_oci -Path $php_dir
} else {
if(-not(Test-Path $ext_dir\php_oci8.dll)) {
$status = 'Installed and enabled'
$ociVersion = '2.2.0'
if ($version -eq '7.0') {
$ociVersion = '2.1.8'
} elseif ($version -lt '7.0') {
$ociVersion = '2.0.12'
}
$ociUrl = Get-PeclArchiveUrl oci8 $ociVersion $installed
Invoke-WebRequest -UseBasicParsing -Uri $ociUrl -OutFile $php_dir\oci8.zip
Expand-Archive -Path $php_dir\oci8.zip -DestinationPath $ext_dir -Force
2020-07-26 17:18:19 +07:00
}
Add-Content -Value "`r`nextension=php_oci8.dll" -Path $php_dir\php.ini
}
2020-07-26 17:18:19 +07:00
Add-Log $tick $extension $status
Add-LicenseLog
} catch {
Add-Log $cross $extension "Could not install $extension on PHP $( $installed.FullVersion )"
2020-07-15 11:15:40 +07:00
}
}