Skip to content

Instantly share code, notes, and snippets.

@devkabir
Created March 11, 2025 06:50
Show Gist options
  • Select an option

  • Save devkabir/96e55b711d35d70b4a67e66045491a9a to your computer and use it in GitHub Desktop.

Select an option

Save devkabir/96e55b711d35d70b4a67e66045491a9a to your computer and use it in GitHub Desktop.
WP-CLI nightly installation in windows
# Define the directory and file paths
$cliDir = "C:\wp-cli-nightly"
$cliPharPath = "$cliDir\wp-cli.phar"
$batchFilePath = "$cliDir\wp-nightly.bat"
# Create the directory if it doesn't exist
if (-not (Test-Path -Path $cliDir)) {
New-Item -ItemType Directory -Path $cliDir -Force
}
# Download the WP-CLI nightly Phar file
$wpcliUrl = "https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli-nightly.phar"
Invoke-WebRequest -Uri $wpcliUrl -OutFile $cliPharPath
# Create a batch file to run WP-CLI with the 'wp-nightly' command
$batchFileContent = "@ECHO OFF`nphp `"$cliPharPath`" %*"
Set-Content -Path $batchFilePath -Value $batchFileContent
# Add the directory to the system PATH
$envName = "Path"
$envScope = [System.EnvironmentVariableTarget]::Machine
$currentPath = [System.Environment]::GetEnvironmentVariable($envName, $envScope)
if ($currentPath -notlike "*$cliDir*") {
Start-Process powershell -ArgumentList "c:\Users\Luffy\Desktop\wp-nightly.ps1" -Verb RunAs
}
Write-Host "WP-CLI nightly has been installed and registered as 'wp-nightly'. Please restart your terminal or run 'refreshenv' to apply the changes."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment