Skip to content

Commit da72908

Browse files
committed
Add support for pre-installed PHP
1 parent b6d8115 commit da72908

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ Disable coverage for these reasons:
410410
- Accepts `lowest` to set up the lowest supported PHP version.
411411
- Accepts `highest` or `latest` to set up the latest stable PHP version.
412412
- Accepts `nightly` to set up a nightly build from the master branch of PHP.
413+
- 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.
413414
- Accepts the format `d.x`, where `d` is the major version. For example `5.x`, `7.x` and `8.x`.
414415
- See [PHP support](#tada-php-support) for the supported PHP versions.
415416
- If not specified, it looks for the following in order:

src/scripts/darwin.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ get_scan_dir() {
213213
setup_php() {
214214
step_log "Setup PHP"
215215
php_config="$(command -v php-config 2>/dev/null)"
216+
check_pre_installed
216217
existing_version=$(get_brewed_php)
217218
if [[ "$version" =~ ${old_versions:?} ]]; then
218219
run_script "php5-darwin" "${version/./}" >/dev/null 2>&1

src/scripts/linux.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ setup_php() {
246246
step_log "Setup PHP"
247247
sudo mkdir -m 777 -p /var/run /run/php
248248
php_config="$(command -v php-config)"
249+
check_pre_installed
249250
if [[ -z "$php_config" ]] || [ "$(php_semver | cut -c 1-3)" != "$version" ]; then
250251
if [ ! -e "/usr/bin/php$version" ] || [ ! -e "/usr/bin/php-config$version" ]; then
251252
add_php >/dev/null 2>&1

src/scripts/unix.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,19 @@ self_hosted_setup() {
184184
fi
185185
}
186186

187+
# Function to check pre-installed PHP
188+
check_pre_installed() {
189+
if [ "$version" = "pre" ]; then
190+
if [ -n "$php_config" ]; then
191+
version="$(php_semver | cut -c 1-3)"
192+
update=false
193+
else
194+
fail_fast=true
195+
add_log "$cross" "PHP" "No pre-installed PHP version found"
196+
fi
197+
fi
198+
}
199+
187200
# Function to configure PHP
188201
configure_php() {
189202
add_php_config

src/scripts/win32.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,15 @@ if (Test-Path -LiteralPath $php_dir -PathType Container) {
401401
}
402402
$status = "Installed"
403403
$extra_version = ""
404+
if($version -eq 'pre') {
405+
if($null -ne $installed) {
406+
$version = $installed.MajorMinorVersion
407+
$env:update = 'false'
408+
} else {
409+
Add-Log $cross "PHP" "No pre-installed PHP version found"
410+
Write-Error "No pre-installed PHP version found" -ErrorAction Stop
411+
}
412+
}
404413
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
405414
if ($version -lt '7.0' -and ($null -eq (Get-Module -ListAvailable -Name VcRedist))) {
406415
Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" Get-VcList >$null 2>&1

0 commit comments

Comments
 (0)