Hi!
I’ve been trying to get started with WP-CLI, but I can’t understand how it works. As I have understood it, Trellis comes with WP-CLI. But I don’t know how to do.
I’ve tried to SSH into Trellis and use wp-cli from there, but without success. If I write try to find out which version is installed I see that there is no version installed. vagrant@demoshop:~$ which wp-cli vagrant@demoshop:~$
I’ve found some files inside of trellis/roles/wp-cli. Shouldn’t this work out of the box after running vagrant up?
The command for WP-CLI is wp and you can find where it’s installed using which wp; this should give you /usr/bin/wp.
http://wp-cli.org/commands/ is a good place to start learning what commands are available and what it does. I use it primarily for exporting and importing databases from environment to environment but it can do quite a lot more.
Still, I have one more question. I’ve started to use PHPStorm, and I really like it with Roots. I’ve configured Gulp, Vagrant and database from PhpStorm, but the last thing I want to control is WP-CLI.
PhpStorm has support for WP-CLI, but I don’t know how to connect it. Since WP-CLI is installed in Trellis, usr/bin/wp, I’m not sure how to point it to the correct path.
Is this possible? Or do I have to install WP-CLI on my local machine?
WP-CLI is installed by Trellis automatically. The wp command is available globally but you need to run the command from your site root such as /srv/www/example.com/current.
So you need to SSH into your Vagrant box or server, go to that directory, and then run wp commands.
@ben is working on a blog post to show how to use https://github.com/xwp/wp-cli-ssh which lets you run WP-CLI commands locally skipping the manual SSH part.
Maybe I should create a new topic for this, but it seems relevant so:
I’m very familiar and comfortable with WP-CLI, but when I’m running wp db export in any of the following folders I’m getting sh: mysqldump: command not found.
It leaves me with the question of “Where is WP-CLI commands suppose to be run?”
I am getting same error “-bash: wp: command not found” on existing project, there are a few other posts with this issue, but none seems to have solution to this problem.