Vscode doesn't allow running WP-CLI commands

Hello everybody,
While Local’s “Open Site Shell” allows running WP-CLI commands, is there a way to use them seamlessly within VS Code’s integrated terminal for a smoother workflow?

I get the error below when i try wp acorn make:component test) in vscode :

Deprecated: Creation of dynamic property WP_CLI\Dispatcher\Subcommand::$longdesc is deprecated in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CompositeCommand.php on line 38
Error: Error establishing a database connection.

Thank you

This works for me inside VS Code’s terminal, so I don’t think the issues are specific to VS Code. But there are a couple of things going on in your output:

  1. It looks like that deprecation notice may be related to your WP-CLI and PHP versions. Try wp cli update and see if that helps there. I think 2.9.0 is the latest.

  2. As far as the database connection error, that’s because wp-cli isn’t able to access your database with the db config values found in wp-config.php. I don’t have specific experience with Local, but you could try changing DB_HOST from localhost to 127.0.0.1. I have seen that fix wp-cli db connections in the past.

1 Like

Thank you
I’ll give it a try