Skip to content

Commit c2b8c8b

Browse files
authored
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>
1 parent dcfdb2f commit c2b8c8b

2 files changed

Lines changed: 110 additions & 4 deletions

File tree

install.ps1

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#Requires -Version 5.1
2+
<#
3+
.SYNOPSIS
4+
Downloads and installs the latest FrankenPHP release for Windows.
5+
.DESCRIPTION
6+
This script downloads the latest FrankenPHP Windows release from GitHub
7+
and extracts it to the specified directory (~\.frankenphp by default).
8+
9+
Usage as a one-liner:
10+
irm https://github.com/php/frankenphp/raw/refs/heads/main/install.ps1 | iex
11+
Custom install directory:
12+
$env:FRANKENPHP_INSTALL = 'C:\frankenphp'; irm https://github.com/php/frankenphp/raw/refs/heads/main/install.ps1 | iex
13+
#>
14+
15+
$ErrorActionPreference = "Stop"
16+
17+
if ($env:FRANKENPHP_INSTALL) {
18+
$BinDir = $env:FRANKENPHP_INSTALL
19+
} else {
20+
$BinDir = Join-Path $HOME ".frankenphp"
21+
}
22+
23+
Write-Host "Querying latest FrankenPHP release..." -ForegroundColor Cyan
24+
25+
try {
26+
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/php/frankenphp/releases/latest"
27+
} catch {
28+
Write-Host "Could not query GitHub releases: $_" -ForegroundColor Red
29+
exit 1
30+
}
31+
32+
$asset = $release.assets | Where-Object { $_.name -match "Win32-vs17-x64\.zip$" } | Select-Object -First 1
33+
34+
if (-not $asset) {
35+
Write-Host "Could not find a Windows release asset." -ForegroundColor Red
36+
Write-Host "Check https://github.com/php/frankenphp/releases for available downloads." -ForegroundColor Red
37+
exit 1
38+
}
39+
40+
Write-Host "Downloading $($asset.name)..." -ForegroundColor Cyan
41+
42+
$tmpZip = Join-Path $env:TEMP "frankenphp-windows-$PID.zip"
43+
44+
try {
45+
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $tmpZip
46+
} catch {
47+
Write-Host "Download failed: $_" -ForegroundColor Red
48+
exit 1
49+
}
50+
51+
Write-Host "Extracting to $BinDir..." -ForegroundColor Cyan
52+
53+
if (-not (Test-Path $BinDir)) {
54+
New-Item -ItemType Directory -Path $BinDir -Force | Out-Null
55+
}
56+
57+
try {
58+
Expand-Archive -Force -Path $tmpZip -DestinationPath $BinDir
59+
} finally {
60+
Remove-Item $tmpZip -Force -ErrorAction SilentlyContinue
61+
}
62+
63+
Write-Host ""
64+
Write-Host "FrankenPHP downloaded successfully to $BinDir" -ForegroundColor Green
65+
66+
# Check if the directory is in PATH
67+
$inPath = $env:PATH -split ";" | Where-Object { $_ -eq $BinDir -or $_ -eq "$BinDir\" }
68+
if (-not $inPath) {
69+
Write-Host "Add $BinDir to your PATH to use frankenphp.exe globally:" -ForegroundColor Yellow
70+
Write-Host " [Environment]::SetEnvironmentVariable('PATH', `"$BinDir;`" + [Environment]::GetEnvironmentVariable('PATH', 'User'), 'User')" -ForegroundColor Gray
71+
}
72+
73+
Write-Host ""
74+
Write-Host "If you like FrankenPHP, please give it a star on GitHub: https://github.com/php/frankenphp" -ForegroundColor Cyan

install.sh

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ARCH=$(uname -m)
1616
GNU=""
1717

1818
if ! command -v curl >/dev/null 2>&1; then
19-
echo "Please install curl to download FrankenPHP"
19+
echo "Please install curl to download FrankenPHP"
2020
exit 1
2121
fi
2222

@@ -126,9 +126,41 @@ Darwin*)
126126
;;
127127
esac
128128
;;
129-
Windows | MINGW64_NT*)
130-
echo "❗ Use WSL to run FrankenPHP on Windows: https://learn.microsoft.com/windows/wsl/"
131-
exit 1
129+
CYGWIN_NT* | MSYS_NT* | MINGW*)
130+
if ! command -v unzip >/dev/null 2>&1 && ! command -v powershell.exe >/dev/null 2>&1; then
131+
echo "❗ Please install unzip or ensure PowerShell is available to extract FrankenPHP"
132+
exit 1
133+
fi
134+
135+
WIN_ASSET=$(curl -s https://api.github.com/repos/php/frankenphp/releases/latest |
136+
grep -o '"name": *"frankenphp-[^"]*-Win32-vs17-x64\.zip"' | head -1 |
137+
sed 's/"name": *"//;s/"//')
138+
139+
if [ -z "${WIN_ASSET}" ]; then
140+
echo "❗ Could not find a Windows release asset"
141+
echo "❗ Check https://github.com/php/frankenphp/releases for available downloads"
142+
exit 1
143+
fi
144+
145+
echo "📦 Downloading ${bold}FrankenPHP${normal} for Windows (x64):"
146+
147+
TMPZIP="/tmp/frankenphp-windows-$$.zip"
148+
curl -L --progress-bar "https://github.com/php/frankenphp/releases/latest/download/${WIN_ASSET}" -o "${TMPZIP}"
149+
150+
echo "📂 Extracting to ${italic}${BIN_DIR}${normal}..."
151+
if command -v unzip >/dev/null 2>&1; then
152+
unzip -o -q "${TMPZIP}" -d "${BIN_DIR}"
153+
else
154+
powershell.exe -Command "Expand-Archive -Force -Path '$(cygpath -w "${TMPZIP}")' -DestinationPath '$(cygpath -w "${BIN_DIR}")'"
155+
fi
156+
rm -f "${TMPZIP}"
157+
158+
echo
159+
echo "🥳 FrankenPHP downloaded successfully to ${italic}${BIN_DIR}${normal}"
160+
echo "🔧 Add ${italic}$(cygpath -w "${BIN_DIR}")${normal} to your Windows PATH to use ${italic}frankenphp.exe${normal} globally."
161+
echo
162+
echo "⭐ If you like FrankenPHP, please give it a star on GitHub: ${italic}https://github.com/php/frankenphp${normal}"
163+
exit 0
132164
;;
133165
*)
134166
THE_ARCH_BIN=""

0 commit comments

Comments
 (0)