Issue Installing Plugin With Composer and WP-CLI

I’m on El Capitan. Trying to install my first plugin. Bought the soil plugin today to support it even though its available via GitHub and Packagist.

Went to packagist and got this command:
composer require roots/soil 3.6.0

Ran that successfully.

Next I ran:

wp plugin activate soil

But it says, “wp: command not found”. I had assumed wp-cli gets installed automatically at some point during the trellis and bedrock and sage installation. Do I need to install this separately (http://wp-cli.org/) and if so anything special to note to get it to work in the trellis/bedrock/sage world?

In /web/ there is a file called wp-cli.yml.

Or if it should work out of the box any thoughts on why it might not be? I’ll keep Google searching an experimenting in the mean time. Thanks!

Since you’re using Trellis, WP-CLI is installed on your Vagrant box as well as remote servers you provision with Trellis.

To use it you need to login to your dev box via SSH. From the directory where your Vagrantfile resides, run vagrant ssh. From there you’ll need to change directories to your site (/srv/www/example.com/current/).

The whole sequence (using the roots-example-project as an example):

$ vagrant ssh
Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-49-generic x86_64)
vagrant@roots-example-project:~$ cd /srv/www/roots-example-project.com/current/
vagrant@roots-example-project:/srv/www/roots-example-project.com/current$ wp plugin activate soil
Success: Plugin 'soil' activated.

You’ll want to use vagrant ssh to get into your dev box to run Composer, WP-CLI, etc. instead of doing it from your local/host machine.

2 Likes

Thanks for that help!

I changed into the trellis directory on my local machine and ran vagrant ssh and logged me into the ubuntu vagrant server and see the site there in the directories you mentioned.

However, I’ve been working on the site today via the files on my computer in Sites/example.com/ which includes trellis and site folder, bedrock sage etc. Do all the files I edit and work on their in my sites folder sync with the vargrant server or are they completely seperate? It looks like they are in sync.

So does that mean I can continue working in sites as normal and then only login to vagrant ssh, if I need to run a wp-cli command and composer commands? But everything else like bower, gulp etc would be done locally?

*Just to add, your solution works and was able to successfully install soil. The question above is more a follow up based on your explanation so I can best understand when to use vagrant and when to just use local, during development. I’ve tried roots in the past but hit so many road blocks that I always gave up up on it. But finally making a lot of progress as I so want to use it since it’s clearly the leader in best practices for WP.

You got it

Yup, that’s the way to go

1 Like