From e9b042d1a5e336f4b82f92ce39c26ec8612cfccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Sun, 1 Mar 2026 20:07:12 +0100 Subject: [PATCH 1/4] feat: install script for Windows --- install.ps1 | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++ install.sh | 38 ++++++++++++++++++++++++--- 2 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 install.ps1 diff --git a/install.ps1 b/install.ps1 new file mode 100644 index 000000000..c1c4bd699 --- /dev/null +++ b/install.ps1 @@ -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 (current directory by default). + + Usage as a one-liner: + irm https://github.com/php/frankenphp/raw/refs/heads/main/install.ps1 | iex + Custom install directory: + $env:BIN_DIR = 'C:\frankenphp'; irm https://github.com/php/frankenphp/raw/refs/heads/main/install.ps1 | iex +#> + +$ErrorActionPreference = "Stop" + +if ($env:BIN_DIR) { + $BinDir = $env:BIN_DIR +} else { + $BinDir = Get-Location +} + +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 -UseBasicParsing +} 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 diff --git a/install.sh b/install.sh index 0213ab6c8..a92235077 100755 --- a/install.sh +++ b/install.sh @@ -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 +Windows | 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 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}${BIN_DIR}${normal} to your 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="" From 4d22f95fdcde868c1057ba403ed630f8bd7ace37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 2 Mar 2026 11:07:26 +0100 Subject: [PATCH 2/4] shfmt --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index a92235077..83c69f65d 100755 --- a/install.sh +++ b/install.sh @@ -132,8 +132,8 @@ Windows | CYGWIN_NT* | MSYS_NT* | MINGW*) 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 | \ + 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 From c52b2e7b7845878e378e2e83b7ce1be151a2cef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 2 Mar 2026 11:31:53 +0100 Subject: [PATCH 3/4] review --- install.ps1 | 4 ++-- install.sh | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/install.ps1 b/install.ps1 index c1c4bd699..df3e541ae 100644 --- a/install.ps1 +++ b/install.ps1 @@ -17,7 +17,7 @@ $ErrorActionPreference = "Stop" if ($env:BIN_DIR) { $BinDir = $env:BIN_DIR } else { - $BinDir = Get-Location + $BinDir = (Get-Location).Path } Write-Host "Querying latest FrankenPHP release..." -ForegroundColor Cyan @@ -42,7 +42,7 @@ 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 -UseBasicParsing + Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $tmpZip } catch { Write-Host "Download failed: $_" -ForegroundColor Red exit 1 diff --git a/install.sh b/install.sh index 83c69f65d..9ab8321b1 100755 --- a/install.sh +++ b/install.sh @@ -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,9 @@ Darwin*) ;; esac ;; -Windows | CYGWIN_NT* | MSYS_NT* | MINGW*) +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 to extract FrankenPHP" + echo "❗ Please install unzip or ensure PowerShell is available to extract FrankenPHP" exit 1 fi @@ -157,7 +157,7 @@ Windows | CYGWIN_NT* | MSYS_NT* | MINGW*) echo echo "🥳 FrankenPHP downloaded successfully to ${italic}${BIN_DIR}${normal}" - echo "🔧 Add ${italic}${BIN_DIR}${normal} to your PATH to use ${italic}frankenphp.exe${normal} globally." + 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 From 23f2f7f950590715df2daa10694f20f7aa467abe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 2 Mar 2026 11:39:31 +0100 Subject: [PATCH 4/4] change default install location --- install.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/install.ps1 b/install.ps1 index df3e541ae..38d9a81be 100644 --- a/install.ps1 +++ b/install.ps1 @@ -4,20 +4,20 @@ 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 (current directory by default). + 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:BIN_DIR = 'C:\frankenphp'; irm https://github.com/php/frankenphp/raw/refs/heads/main/install.ps1 | iex + $env:FRANKENPHP_INSTALL = 'C:\frankenphp'; irm https://github.com/php/frankenphp/raw/refs/heads/main/install.ps1 | iex #> $ErrorActionPreference = "Stop" -if ($env:BIN_DIR) { - $BinDir = $env:BIN_DIR +if ($env:FRANKENPHP_INSTALL) { + $BinDir = $env:FRANKENPHP_INSTALL } else { - $BinDir = (Get-Location).Path + $BinDir = Join-Path $HOME ".frankenphp" } Write-Host "Querying latest FrankenPHP release..." -ForegroundColor Cyan