2020-07-26 17:18:19 +07:00
|
|
|
# Function to install phalcon
|
|
|
|
Function Add-PhalconHelper() {
|
|
|
|
if ($extension_version -eq '4') {
|
|
|
|
Install-Phpextension phalcon -MinimumStability stable -Path $php_dir
|
|
|
|
} else {
|
|
|
|
$domain = 'https://github.com'
|
|
|
|
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
|
2020-11-11 03:53:45 +07:00
|
|
|
$match = Invoke-WebRequest -Uri $domain/phalcon/cphalcon/releases | Select-String -Pattern "href=`"(.*phalcon_x64_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)`""
|
2020-07-26 17:18:19 +07:00
|
|
|
$zip_file = $match.Matches[0].Groups[1].Value
|
2020-11-11 03:53:45 +07:00
|
|
|
Invoke-WebRequest -Uri $domain/$zip_file -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip > $null 2>&1
|
2020-07-26 17:18:19 +07:00
|
|
|
Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force > $null 2>&1
|
|
|
|
Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll" -Destination "$ext_dir\php_phalcon.dll"
|
|
|
|
Enable-PhpExtension -Extension phalcon -Path $php_dir
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Function Add-Phalcon() {
|
|
|
|
Param (
|
2019-12-26 20:01:18 +07:00
|
|
|
[Parameter(Position = 0, Mandatory = $true)]
|
|
|
|
[ValidateNotNull()]
|
|
|
|
[ValidateSet('phalcon3', 'phalcon4')]
|
|
|
|
[string]
|
2020-07-26 17:18:19 +07:00
|
|
|
$extension
|
|
|
|
)
|
|
|
|
try {
|
|
|
|
$status = 'Enabled'
|
|
|
|
$extension_version = $extension.substring($extension.Length - 1)
|
2020-01-21 19:28:09 +07:00
|
|
|
|
2020-07-26 17:18:19 +07:00
|
|
|
if($extension_version -eq '4') {
|
|
|
|
if (Test-Path $ext_dir\php_psr.dll) {
|
2020-01-21 19:28:09 +07:00
|
|
|
Enable-PhpExtension -Extension psr -Path $php_dir
|
2020-07-26 17:18:19 +07:00
|
|
|
} else {
|
2020-01-21 19:28:09 +07:00
|
|
|
Install-Phpextension psr -MinimumStability stable -Path $php_dir
|
2020-07-26 17:18:19 +07:00
|
|
|
}
|
2020-01-21 19:28:09 +07:00
|
|
|
}
|
|
|
|
|
2020-07-26 17:18:19 +07:00
|
|
|
if(Test-Path $ext_dir\php_phalcon.dll) {
|
|
|
|
$phalcon = Get-PhpExtension $ext_dir\php_phalcon.dll
|
|
|
|
if($phalcon.Version[0] -eq $extension_version) {
|
2020-01-21 19:28:09 +07:00
|
|
|
Enable-PhpExtension -Extension phalcon -Path $php_dir
|
2020-07-26 17:18:19 +07:00
|
|
|
} else {
|
|
|
|
$status = 'Installed and enabled'
|
2020-01-21 19:28:09 +07:00
|
|
|
Remove-Item $ext_dir\php_phalcon.dll
|
2020-07-26 17:18:19 +07:00
|
|
|
Add-PhalconHelper
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$status = 'Installed and enabled'
|
|
|
|
Add-PhalconHelper
|
2020-01-21 19:28:09 +07:00
|
|
|
}
|
2020-07-26 17:18:19 +07:00
|
|
|
Add-Log $tick $extension $status
|
|
|
|
} catch [Exception] {
|
|
|
|
Write-Output $_.Exception|format-list -force
|
|
|
|
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
|
|
|
|
}
|
|
|
|
}
|