Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion linux/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

set -e

PHPVM_VERSION="1.12.0"
PHPVM_VERSION="1.12.1"
PHPVM_DIR="${PHPVM_DIR:-$HOME/.phpvm}"
PHPVM_REPO="https://raw.githubusercontent.com/devhardiyanto/phpvm/main"

Expand Down
8 changes: 4 additions & 4 deletions linux/phpvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# phpvm use 8.3.0
# ==============================================================================

PHPVM_VERSION="1.12.0"
PHPVM_VERSION="1.12.1"
PHPVM_DIR="${PHPVM_DIR:-$HOME/.phpvm}"
PHPVM_VERSIONS="$PHPVM_DIR/versions"
PHPVM_CURRENT="$PHPVM_DIR/current"
Expand All @@ -19,7 +19,7 @@ PHPVM_CACHE="$PHPVM_DIR/cache"
PHPVM_LOG="$PHPVM_DIR/build.log"
PHPVM_UPDATE_URL="https://raw.githubusercontent.com/devhardiyanto/phpvm/main/version.txt"
PHPVM_LAST_CHECK="$PHPVM_DIR/.last_update_check"
PHPVM_CHECK_INTERVAL=86400 # 24 hours
PHPVM_CHECK_INTERVAL=3600 # 1 hour

# ── Colors ────────────────────────────────────────────────────────────────────
# printf (not echo -e): the message is passed through %s so backslashes in the
Expand All @@ -32,12 +32,12 @@ _step() { printf ' \033[36m> %s\033[0m\n' "$*"; }
_warn() { printf ' \033[33m[warn] %s\033[0m\n' "$*"; }
_dim() { printf ' \033[90m%s\033[0m\n' "$*"; }

# ── Update checker (once per day, via version.txt) ───────────────────────────
# ── Update checker (hourly, via version.txt) ─────────────────────────────────
_phpvm_check_update() {
# Skip in CI or if explicitly disabled
[[ -n "${CI:-}" || -n "${PHPVM_NO_UPDATE_CHECK:-}" ]] && return

# Only check once per day
# Only check once per interval
if [[ -f "$PHPVM_LAST_CHECK" ]]; then
local last_ts now elapsed
# GNU stat (-c) on Linux, BSD stat (-f) on macOS.
Expand Down
18 changes: 18 additions & 0 deletions tests/windows/Doctor.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,22 @@ Describe 'Invoke-Doctor' {

$out | Should -Match 'Active PHP version: 8\.3\.0'
}

Context 'Test-ExtDirMatch (ext_dir junction equivalence)' {
It 'Accepts the version-specific ext path' {
Test-ExtDirMatch "$VERSIONS_DIR\8.5.6\ext" '8.5.6' | Should -BeTrue
}
It 'Accepts the current\ext junction spelling' {
Test-ExtDirMatch "$CURRENT_LINK\ext" '8.5.6' | Should -BeTrue
}
It 'Ignores a trailing backslash' {
Test-ExtDirMatch "$VERSIONS_DIR\8.5.6\ext\" '8.5.6' | Should -BeTrue
}
It 'Rejects an unrelated extension_dir' {
Test-ExtDirMatch 'C:\xampp\php\ext' '8.5.6' | Should -BeFalse
}
It 'Rejects an empty extension_dir' {
Test-ExtDirMatch '' '8.5.6' | Should -BeFalse
}
}
}
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.12.0
1.12.1
2 changes: 1 addition & 1 deletion windows/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

$PHPVM_VERSION = "1.12.0"
$PHPVM_VERSION = "1.12.1"
$PHPVM_DIR = if ($env:PHPVM_DIR) { $env:PHPVM_DIR } else { "$env:USERPROFILE\.phpvm" }
$PHPVM_BIN = "$PHPVM_DIR\bin"

Expand Down
19 changes: 15 additions & 4 deletions windows/phpvm.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

# -- Constants -----------------------------------------------------------------
$PHPVM_VERSION = "1.12.0"
$PHPVM_VERSION = "1.12.1"
$PHPVM_DIR = if ($env:PHPVM_DIR) { $env:PHPVM_DIR } else { "$env:USERPROFILE\.phpvm" }
$VERSIONS_DIR = "$PHPVM_DIR\versions"
$CURRENT_LINK = "$PHPVM_DIR\current"
$PHPVM_BIN = "$PHPVM_DIR\bin"
$PHPVM_CACERT = "$PHPVM_DIR\cacert.pem"
$PHPVM_CACERT_URL = "https://curl.se/ca/cacert.pem"

# -- Update checker (once per day, via version.txt) ---------------------------
# -- Update checker (hourly, via version.txt) ---------------------------------
$PHPVM_UPDATE_URL = "https://raw.githubusercontent.com/devhardiyanto/phpvm/main/version.txt"
$PHPVM_LAST_CHECK = "$PHPVM_DIR\.last_update_check"
$PHPVM_CHECK_INTERVAL = 86400 # 24 hours in seconds
$PHPVM_CHECK_INTERVAL = 3600 # 1 hour in seconds

function Check-PHPVMUpdate {
if ($env:CI -or $env:PHPVM_NO_UPDATE_CHECK) { return }
Expand Down Expand Up @@ -1593,6 +1593,17 @@ function Invoke-Cacert ([string]$sub) {


# Read-only health check. Never mutates state - every finding points at the
# True when the ini's extension_dir points at the active version's ext folder.
# `current` is a junction to versions\<cur>, so the versions\<cur>\ext and
# current\ext spellings name the same directory - accept either rather than
# string-comparing and false-flagging a valid setup.
function Test-ExtDirMatch ([string]$iniExtDir, [string]$cur) {
if (-not $iniExtDir) { return $false }
$acceptable = @("$VERSIONS_DIR\$cur\ext", "$CURRENT_LINK\ext") |
ForEach-Object { $_.TrimEnd('\') }
return ($acceptable -icontains $iniExtDir.TrimEnd('\'))
}

# command that fixes it. Exit-code-neutral: it's a report, not a gate.
function Invoke-Doctor {
Write-Host ""
Expand Down Expand Up @@ -1638,7 +1649,7 @@ function Invoke-Doctor {
$info = Get-PHPBuildInfo
if ($info.IniPath -and (Test-Path $info.IniPath)) {
$iniExtDir = Invoke-PHP $info.Exe "echo ini_get('extension_dir');"
if ($iniExtDir -and ($iniExtDir.TrimEnd('\') -ieq $info.ExtDir.TrimEnd('\'))) {
if (Test-ExtDirMatch $iniExtDir $cur) {
Doctor-Ok "extension_dir matches active build."
} else {
Doctor-Warn "extension_dir mismatch: '$iniExtDir' != '$($info.ExtDir)'"
Expand Down
Loading