Bedrock: wp-cli error

I have wp-cli installed globally and when trying to run “wp” command in the “web” directory it throws a PHP Fatal error:

PHP Fatal error: Cannot redeclare cli\render() (previously declared in phar:///usr/bin/wp/vendor/wp-cli/php-cli-tools/lib/cli/cli.php:26) in /… src/vendor/wp-cli/php-cli-tools/lib/cli/cli.php on line 28

If I remove wp-cli from composer’s dependencies, delete the wp-cli folder from vendor and run a composer update, I am able to run wp-cli as normal. It looks like Bedrock already installs wp-cli, as it’s autoloaded through Composer dependency, however I’m not quite sure how I can actually use it, and there isn’t any documentation on this that I can find.

I haven’t yet been able to find a way that wp-cli can be used as a composer dependency (wp-cli docs say it’s been depreciated??) Any help is appreciated, thanks!


I know there’s been some issues in the past with wp-cli installs conflicting (global vs local Composer version).

I’ve just left it alone until now, but I think it makes sense to remove wp-cli from Bedrock entirely and just let people handle it on their own via the suggested install method.

Once we have our integrated Ansible/Vagrant part too, we’ll just use that to install wp-cli.

Right on, I had a feeling it was there to help with Vagrant, and for my own workflow I’d like to use wp-cli to automate plugin and theme installs/uninstalls, similar to LaravelPHP & Ruby’s Migrations (only in this case it wouldn’t be setting up scheme but rather Wordpress dependency upgrading, etc).

Do you have a dev branch with the Vagrant workflow that I can help contribute to?

Also, I was thinking of contributing a version that integrates Rocketeer deployment (PHP version of Capistrano). Not sure if you guys have worked with Rocketeer or were thinking of incorporating anything along those lines in the vanilla Bedrock.

Right now the Ansible work is just in a private repo, but hopefully by next week we’ll open it up. We just want it working first then work on improving it with the help of others.

I first found out about Rocketeer a couple months ago and thought it looked pretty good. It would be nice to have everything in the same language if possible so it’s something we’ll look into in the future. Wouldn’t be hard for someone to make it an option as well.

Right on, yeah makes sense.

Figured I’d update you that we fixed the error you had with WP-CLI by removing it from composer.json. And included a default wp-cli.yml so the wp command will work as usual from anywhere within a Bedrock project.

Yeah I saw that, I wondered if it might be related :smile: