WP-CLI (http://wp-cli.org/) is a great commandline tool to manage your WordPress installation. It has countless commands. For example to:
- change database settings
- clear the cache
- manage comments and posts
- install plugins
- …
The “normal” installation is well documented on the project page. But I prefer to store my project tools (f.e.: vagrant, coposer, etc.) in a different tool folder that is separated from the WordPress installation.
To use wp-cli you have to take the following steps:
- Download the source into a folder where you wish to use the tool (f.e. ):
$> wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
- Now you can call wp-cli like that
$> php wp-cli.phar --path=/var/www/docroot/ help
from within the install folder.
-
Make wp globally available, so you can use it everywhere in your product structure:
$> chmod +x wp-cli.phar # make it executable $> sudo cp wp-cli.phar /usr/local/bin/wp #copy it
This step has to be repeated after every update!
- Now you can use wp as a “normal” command (but in my case I have to add the path param every time)
- As an alternative you can add a bash alias for the wp command with the path param (see command above):
- open .bash_aliases to edit it
$> nano ~/.bash_aliases
- add the following line
alias wp='php /var/www/tools/wp-cli/wp-cli.phar --path=/var/www/docroot/'
Now you can call wp without the path param from any path within your project.
- open .bash_aliases to edit it
- Call $> wp help  to get information about usage
1 thoughts on “Install WP-CLI into a separated folder”