Skip to content

Commit cae6d06

Browse files
committed
Improve phalcon support
1 parent 89f4f7e commit cae6d06

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

src/scripts/extensions/phalcon.ps1

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,45 @@ Function Add-PhalconFromGitHub() {
66
[string]
77
$Semver
88
)
9-
$domain = 'https://github.com'
9+
$domain = 'https://api.github.com/repos'
1010
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
11-
$match = Invoke-WebRequest -Uri "$domain/phalcon/cphalcon/releases/v$Semver" | Select-String -Pattern "href=`"(.*phalcon_x64_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)`""
11+
$match = $match = (Invoke-RestMethod -Uri "$domain/phalcon/cphalcon/releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=(.*phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
1212
if($NULL -eq $match) {
1313
$nts = if (!$installed.ThreadSafe) { "-nts" } else { "-ts" }
14-
$match = Invoke-WebRequest -Uri "$domain/phalcon/cphalcon/releases/v$Semver" | Select-String -Pattern "href=`"(.*phalcon-php${version}${nts}-windows.*-x64.zip)`""
14+
$match = (Invoke-RestMethod -Uri "$domain/phalcon/cphalcon/releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=(.*phalcon-php${version}${nts}-windows.*-x64.zip)"
1515
}
1616
if($NULL -ne $match) {
17-
$zip_file = $match.Matches[0].Groups[1].Value
18-
Invoke-WebRequest -Uri $domain/$zip_file -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip > $null 2>&1
17+
$zip_url = $match.Matches[0].Groups[1].Value
18+
Invoke-WebRequest -Uri $zip_url -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip > $null 2>&1
1919
Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force > $null 2>&1
2020
Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll" -Destination "$ext_dir\php_phalcon.dll"
2121
Enable-PhpExtension -Extension phalcon -Path $php_dir
2222
} else {
2323
throw "Unable to get Phalcon release from the GitHub release"
2424
}
2525
}
26+
27+
# Function to get phalcon semver.
28+
Function Get-PhalconSemver() {
29+
if($extension_version -eq '3') {
30+
return '3.4.5'
31+
} elseif (($extension_version -eq '4') -and ($version -eq '7.2')) {
32+
return '4.1.0'
33+
}
34+
return Get-PeclPackageVersion phalcon $extension_version stable stable | Select-Object -First 1
35+
}
36+
2637
# Function to install phalcon
2738
Function Add-PhalconHelper() {
28-
if (($extension_version -eq '4') -or ($extension_version -eq '5')) {
29-
$extension_semver=Get-PeclPackageVersion phalcon $extension_version stable stable | Select-Object -First 1
30-
Add-Extension -Extension phalcon -Stability stable -Extension_version $extension_semver
31-
} elseif ($extension_version -eq '3') {
32-
Add-PhalconFromGitHub -Semver 3.4.5
39+
$semver = Get-PhalconSemver
40+
if (($extension_version -eq '3') -or ($extension_version -eq '5')) {
41+
Add-PhalconFromGitHub $semver
42+
} elseif ($extension_version -eq '4') {
43+
Add-Extension -Extension phalcon -Stability stable -Extension_version $semver
3344
}
3445
}
3546

47+
# Function to add phalcon
3648
Function Add-Phalcon() {
3749
Param (
3850
[Parameter(Position = 0, Mandatory = $true)]

src/scripts/extensions/phalcon.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ get_phalcon_version() {
33
if [ "$extension" = "phalcon5" ]; then
44
get_pecl_version phalcon stable 5
55
elif [ "$extension" = "phalcon4" ]; then
6-
echo '4.1.3'
6+
echo '4.1.2'
77
elif [ "$extension" = "phalcon3" ]; then
88
echo '3.4.5'
99
fi
@@ -32,7 +32,7 @@ add_phalcon_helper() {
3232
package="php${version:?}-$extension"
3333
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
3434
[ "$extension" = "phalcon4" ] && (install_packages "php${version:?}-psr" || pecl_install psr || pecl_install psr-1.1.0)
35-
(check_package "$package" && install_packages "$package") || add_phalcon_from_repo
35+
(check_package "$package" && install_packages "$package") || pecl_install phalcon-"$(get_phalcon_version)" || add_phalcon_from_repo
3636
fi
3737
}
3838

@@ -85,7 +85,7 @@ add_phalcon5() {
8585

8686
# Function to add phalcon.
8787
add_phalcon() {
88-
extension=$1
88+
local extension=$1
8989
status='Enabled'
9090
extension_major_version=${extension: -1}
9191
if [[ "$extension_major_version" =~ [3-5] ]]; then

0 commit comments

Comments
 (0)