feat: install script for Windows (#2228)

Update the shell script and add a PowerShell script to install the
Windows binary.

---------

Co-authored-by: Kévin Dunglas <kevin@dunglas.dev>
This commit is contained in:
Kévin Dunglas
2026-03-02 15:31:54 +01:00
committed by GitHub
parent dcfdb2f068
commit c2b8c8b15d
2 changed files with 110 additions and 4 deletions

74
install.ps1 Normal file
View File

@@ -0,0 +1,74 @@
#Requires -Version 5.1
<#
.SYNOPSIS
Downloads and installs the latest FrankenPHP release for Windows.
.DESCRIPTION
This script downloads the latest FrankenPHP Windows release from GitHub
and extracts it to the specified directory (~\.frankenphp by default).
Usage as a one-liner:
irm https://github.com/php/frankenphp/raw/refs/heads/main/install.ps1 | iex
Custom install directory:
$env:FRANKENPHP_INSTALL = 'C:\frankenphp'; irm https://github.com/php/frankenphp/raw/refs/heads/main/install.ps1 | iex
#>
$ErrorActionPreference = "Stop"
if ($env:FRANKENPHP_INSTALL) {
$BinDir = $env:FRANKENPHP_INSTALL
} else {
$BinDir = Join-Path $HOME ".frankenphp"
}
Write-Host "Querying latest FrankenPHP release..." -ForegroundColor Cyan
try {
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/php/frankenphp/releases/latest"
} catch {
Write-Host "Could not query GitHub releases: $_" -ForegroundColor Red
exit 1
}
$asset = $release.assets | Where-Object { $_.name -match "Win32-vs17-x64\.zip$" } | Select-Object -First 1
if (-not $asset) {
Write-Host "Could not find a Windows release asset." -ForegroundColor Red
Write-Host "Check https://github.com/php/frankenphp/releases for available downloads." -ForegroundColor Red
exit 1
}
Write-Host "Downloading $($asset.name)..." -ForegroundColor Cyan
$tmpZip = Join-Path $env:TEMP "frankenphp-windows-$PID.zip"
try {
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $tmpZip
} catch {
Write-Host "Download failed: $_" -ForegroundColor Red
exit 1
}
Write-Host "Extracting to $BinDir..." -ForegroundColor Cyan
if (-not (Test-Path $BinDir)) {
New-Item -ItemType Directory -Path $BinDir -Force | Out-Null
}
try {
Expand-Archive -Force -Path $tmpZip -DestinationPath $BinDir
} finally {
Remove-Item $tmpZip -Force -ErrorAction SilentlyContinue
}
Write-Host ""
Write-Host "FrankenPHP downloaded successfully to $BinDir" -ForegroundColor Green
# Check if the directory is in PATH
$inPath = $env:PATH -split ";" | Where-Object { $_ -eq $BinDir -or $_ -eq "$BinDir\" }
if (-not $inPath) {
Write-Host "Add $BinDir to your PATH to use frankenphp.exe globally:" -ForegroundColor Yellow
Write-Host " [Environment]::SetEnvironmentVariable('PATH', `"$BinDir;`" + [Environment]::GetEnvironmentVariable('PATH', 'User'), 'User')" -ForegroundColor Gray
}
Write-Host ""
Write-Host "If you like FrankenPHP, please give it a star on GitHub: https://github.com/php/frankenphp" -ForegroundColor Cyan

View File

@@ -16,7 +16,7 @@ ARCH=$(uname -m)
GNU=""
if ! command -v curl >/dev/null 2>&1; then
echo "Please install curl to download FrankenPHP"
echo "Please install curl to download FrankenPHP"
exit 1
fi
@@ -126,9 +126,41 @@ Darwin*)
;;
esac
;;
Windows | MINGW64_NT*)
echo "❗ Use WSL to run FrankenPHP on Windows: https://learn.microsoft.com/windows/wsl/"
exit 1
CYGWIN_NT* | MSYS_NT* | MINGW*)
if ! command -v unzip >/dev/null 2>&1 && ! command -v powershell.exe >/dev/null 2>&1; then
echo "❗ Please install unzip or ensure PowerShell is available to extract FrankenPHP"
exit 1
fi
WIN_ASSET=$(curl -s https://api.github.com/repos/php/frankenphp/releases/latest |
grep -o '"name": *"frankenphp-[^"]*-Win32-vs17-x64\.zip"' | head -1 |
sed 's/"name": *"//;s/"//')
if [ -z "${WIN_ASSET}" ]; then
echo "❗ Could not find a Windows release asset"
echo "❗ Check https://github.com/php/frankenphp/releases for available downloads"
exit 1
fi
echo "📦 Downloading ${bold}FrankenPHP${normal} for Windows (x64):"
TMPZIP="/tmp/frankenphp-windows-$$.zip"
curl -L --progress-bar "https://github.com/php/frankenphp/releases/latest/download/${WIN_ASSET}" -o "${TMPZIP}"
echo "📂 Extracting to ${italic}${BIN_DIR}${normal}..."
if command -v unzip >/dev/null 2>&1; then
unzip -o -q "${TMPZIP}" -d "${BIN_DIR}"
else
powershell.exe -Command "Expand-Archive -Force -Path '$(cygpath -w "${TMPZIP}")' -DestinationPath '$(cygpath -w "${BIN_DIR}")'"
fi
rm -f "${TMPZIP}"
echo
echo "🥳 FrankenPHP downloaded successfully to ${italic}${BIN_DIR}${normal}"
echo "🔧 Add ${italic}$(cygpath -w "${BIN_DIR}")${normal} to your Windows PATH to use ${italic}frankenphp.exe${normal} globally."
echo
echo "⭐ If you like FrankenPHP, please give it a star on GitHub: ${italic}https://github.com/php/frankenphp${normal}"
exit 0
;;
*)
THE_ARCH_BIN=""