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.7.0"
PHPVM_VERSION="1.7.1"
PHPVM_DIR="${PHPVM_DIR:-$HOME/.phpvm}"
PHPVM_REPO="https://raw.githubusercontent.com/devhardiyanto/phpvm/main"

Expand Down
54 changes: 53 additions & 1 deletion 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.7.0"
PHPVM_VERSION="1.7.1"
PHPVM_DIR="${PHPVM_DIR:-$HOME/.phpvm}"
PHPVM_VERSIONS="$PHPVM_DIR/versions"
PHPVM_CURRENT="$PHPVM_DIR/current"
Expand Down Expand Up @@ -557,22 +557,74 @@ phpvm_ext_install() {
return 1
}

_phpvm_ext_preflight "$name" || return 1

local ver="${2:-}"
if [[ -n "$ver" ]]; then
_step "Installing $name-$ver via PECL ..."
pecl install "$name-$ver" || {
_err "Failed to install $name-$ver via PECL."
_phpvm_ext_runtime_notes "$name"
return 1
}
else
_step "Installing $name via PECL ..."
pecl install "$name" || {
_err "Failed to install $name via PECL."
_phpvm_ext_runtime_notes "$name"
return 1
}
fi

_ok "Done. Enable with: phpvm ext enable $name"
_phpvm_ext_runtime_notes "$name"
}

# Build-time prerequisites for specific extensions. Warn early instead of
# letting `pecl install` fail mid-build with cryptic compiler errors.
_phpvm_ext_preflight() {
local name="$1"
case "$name" in
sqlsrv|pdo_sqlsrv)
# unixODBC headers (sql.h / sqlext.h) are required to compile sqlsrv.
if command -v odbc_config &>/dev/null; then return 0; fi
local inc
for inc in /usr/include/sql.h /usr/local/include/sql.h \
/opt/homebrew/include/sql.h /opt/homebrew/opt/unixodbc/include/sql.h \
/usr/local/opt/unixodbc/include/sql.h; do
[[ -f "$inc" ]] && return 0
done
_warn "unixODBC development headers not found — required to build $name."
local pm
pm=$(_phpvm_detect_os)
case "$pm" in
apt) _dim "Install: sudo apt-get install -y unixodbc-dev" ;;
dnf) _dim "Install: sudo dnf install -y unixODBC-devel" ;;
yum) _dim "Install: sudo yum install -y unixODBC-devel" ;;
pacman) _dim "Install: sudo pacman -S --needed unixodbc" ;;
zypper) _dim "Install: sudo zypper install -y unixODBC-devel" ;;
brew) _dim "Install: brew install unixodbc" ;;
*) _dim "Install unixODBC development headers via your package manager." ;;
esac
_dim "Then retry: phpvm ext install $name"
return 1
;;
esac
return 0
}

# Post-install advisories for extensions that need extra system components.
_phpvm_ext_runtime_notes() {
local name="$1"
case "$name" in
sqlsrv|pdo_sqlsrv)
echo ""
_dim "Note: $name also requires the Microsoft ODBC Driver for SQL Server"
_dim "to actually connect at runtime. Install (one-off, system-wide):"
_dim " https://learn.microsoft.com/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server"
_dim "Setup guide: https://learn.microsoft.com/sql/connect/php/step-1-configure-development-environment-for-php-development"
;;
esac
}

phpvm_ext_enable() {
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7.0
1.7.1
2 changes: 1 addition & 1 deletion windows/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

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

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

# -- Constants -----------------------------------------------------------------
$PHPVM_VERSION = "1.7.0"
$PHPVM_VERSION = "1.7.1"
$PHPVM_DIR = if ($env:PHPVM_DIR) { $env:PHPVM_DIR } else { "$env:USERPROFILE\.phpvm" }
$VERSIONS_DIR = "$PHPVM_DIR\versions"
$CURRENT_LINK = "$PHPVM_DIR\current"
Expand Down Expand Up @@ -259,13 +259,21 @@ function Get-XDebugHash ([string]$dllUrl) {
}

function Test-URLExists ([string]$url) {
$ProgressPreference = "SilentlyContinue"
# HEAD via Invoke-WebRequest follows 30x redirects (windows.php.net -> downloads.php.net).
try {
$req = [System.Net.WebRequest]::Create($url)
$req.Method = "HEAD"
$res = $req.GetResponse()
$res.Close()
return $true
} catch { return $false }
$r = Invoke-WebRequest -Uri $url -Method Head -MaximumRedirection 5 `
-UseBasicParsing -TimeoutSec 5 -ErrorAction Stop
return ($r.StatusCode -ge 200 -and $r.StatusCode -lt 400)
} catch {
# Some mirrors reject HEAD (405) -- fall back to a 1-byte ranged GET.
try {
$r = Invoke-WebRequest -Uri $url -Method Get -MaximumRedirection 5 `
-UseBasicParsing -TimeoutSec 5 `
-Headers @{ Range = "bytes=0-0" } -ErrorAction Stop
return ($r.StatusCode -ge 200 -and $r.StatusCode -lt 400)
} catch { return $false }
}
}

# ==============================================================================
Expand Down Expand Up @@ -813,6 +821,21 @@ function Install-PECLExt ([string]$extName, [string]$requestedVer = "") {

Remove-Item $tempZip, $tempExtract -Recurse -Force -ErrorAction SilentlyContinue
Write-Ok "Done. Enable with: phpvm ext enable $extName"

Show-ExtRuntimeNotes $extName
}

# Post-install runtime advisories for extensions that need extra system components.
function Show-ExtRuntimeNotes ([string]$extName) {
switch -Regex ($extName.ToLower()) {
'^(sqlsrv|pdo_sqlsrv)$' {
Write-Host ""
Write-Dim "Note: sqlsrv / pdo_sqlsrv also requires the Microsoft ODBC Driver"
Write-Dim "for SQL Server on this machine. Install (one-off, system-wide):"
Write-Dim " https://learn.microsoft.com/sql/connect/odbc/download-odbc-driver-for-sql-server"
Write-Dim "Setup guide: https://learn.microsoft.com/sql/connect/php/step-1-configure-development-environment-for-php-development"
}
}
}

function Install-XDebug {
Expand Down