Dev.to
7/21/2026

Why environment variables don’t suppress WP-CLI PHP Deprecated warnings — the phar + shebang path and a three-part structural fix
Short summary
When WP-CLI runs as a shebang-launched phar binary, the WP_CLI_PHP_ARGS environment variable never reaches PHP's startup, so deprecated warnings persist. The fix detects whether the path invokes PHP directly and injects -d error_reporting immediately after the binary. A secondary helper extracts only the JSON portion from stdout to handle remaining noise.
- •Shebang-launched phar bypasses WP_CLI_PHP_ARGS, so env vars don't suppress PHP warnings
- •Fix: detect php-direct invocation and inject -d error_reporting after the binary
- •JSON extraction helper isolates valid JSON from noisy stdout, reducing parse failures
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



