Skip to main content
SebasVergaraP

Control engineer and full-stack WordPress developer.

Running WP-CLI against a Local site on Windows

1 minute read

Local by Flywheel bundles a PHP binary that loads no php.ini. That is fine for running the site, and fatal for running tooling: extension_dir points at a directory that does not exist, so mysqli never loads and WP-CLI cannot reach the database.

The shim

Local does generate a complete per-site php.ini and records its path in app/.envrc. A wrapper that finds that file and passes it to the binary is all you need.

bin/local-env.ps1
# Local records the generated ini path as PHPRC in app/.envrc.
$ini = ( Select-String -Path $envrc -Pattern 'PHPRC=(.+)' ).Matches.Groups[1].Value

& $php -c $ini @args

Two things that still surprise people

  • DB_HOST is localhost while nothing listens on 3306. Local connects over a named pipe. Leave it alone.
  • PowerShell splits unquoted commas into an array, so --fields=a,b,c arrives as three arguments. Quote it.

Neither is a bug. Both cost an afternoon if you assume they are.

Leave a comment

Your email address will not be published. Required fields are marked.