Running WP-CLI against a Local site on Windows
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.
# 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_HOSTislocalhostwhile nothing listens on 3306. Local connects over a named pipe. Leave it alone.- PowerShell splits unquoted commas into an array, so
--fields=a,b,carrives as three arguments. Quote it.
Neither is a bug. Both cost an afternoon if you assume they are.