Skip to content

Commit

Permalink
Add support for pre-installed PHP
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Dec 23, 2024
1 parent b6d8115 commit da72908
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ Disable coverage for these reasons:
- Accepts `lowest` to set up the lowest supported PHP version.
- Accepts `highest` or `latest` to set up the latest stable PHP version.
- Accepts `nightly` to set up a nightly build from the master branch of PHP.
- Accepts `pre-installed` to set up the highest pre-installed PHP version. You can combine this with `update: true` to update the pre-installed PHP version.
- Accepts the format `d.x`, where `d` is the major version. For example `5.x`, `7.x` and `8.x`.
- See [PHP support](#tada-php-support) for the supported PHP versions.
- If not specified, it looks for the following in order:
Expand Down
1 change: 1 addition & 0 deletions src/scripts/darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ get_scan_dir() {
setup_php() {
step_log "Setup PHP"
php_config="$(command -v php-config 2>/dev/null)"
check_pre_installed
existing_version=$(get_brewed_php)
if [[ "$version" =~ ${old_versions:?} ]]; then
run_script "php5-darwin" "${version/./}" >/dev/null 2>&1
Expand Down
1 change: 1 addition & 0 deletions src/scripts/linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ setup_php() {
step_log "Setup PHP"
sudo mkdir -m 777 -p /var/run /run/php
php_config="$(command -v php-config)"
check_pre_installed
if [[ -z "$php_config" ]] || [ "$(php_semver | cut -c 1-3)" != "$version" ]; then
if [ ! -e "/usr/bin/php$version" ] || [ ! -e "/usr/bin/php-config$version" ]; then
add_php >/dev/null 2>&1
Expand Down
13 changes: 13 additions & 0 deletions src/scripts/unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,19 @@ self_hosted_setup() {
fi
}

# Function to check pre-installed PHP
check_pre_installed() {
if [ "$version" = "pre" ]; then
if [ -n "$php_config" ]; then
version="$(php_semver | cut -c 1-3)"
update=false
else
fail_fast=true
add_log "$cross" "PHP" "No pre-installed PHP version found"
fi
fi
}

# Function to configure PHP
configure_php() {
add_php_config
Expand Down
9 changes: 9 additions & 0 deletions src/scripts/win32.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,15 @@ if (Test-Path -LiteralPath $php_dir -PathType Container) {
}
$status = "Installed"
$extra_version = ""
if($version -eq 'pre') {
if($null -ne $installed) {
$version = $installed.MajorMinorVersion
$env:update = 'false'
} else {
Add-Log $cross "PHP" "No pre-installed PHP version found"
Write-Error "No pre-installed PHP version found" -ErrorAction Stop
}
}
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
if ($version -lt '7.0' -and ($null -eq (Get-Module -ListAvailable -Name VcRedist))) {
Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" Get-VcList >$null 2>&1
Expand Down

0 comments on commit da72908

Please sign in to comment.