9. WHY USE COMMANDS?
•Quickly execute a task
•Bundle many tasks together in scripts
•Avoid using the keyboard and mouse
•Simplify repetitive tasks
•and also…
12. WHAT DO I NEED TO GET STARTED?
•Local Dev Environment with PHP - VVV, MAMP, WAMP
•Terminal - Terminal App, iTerm 2, PuTTY
•Text Editor - Sublime, Atom
PREREQUISITES
18. WHAT HAVE I DONE?
• Installed WP-CLI locally
• Configured a WP-CLI alias to SSH into remotes
• I can execute remote commands as if they were on my local
machine
• No need for local MySQL/PHP/Apache
• Alternate - use SSH directly into VVV using vagrant ssh
19. CONFIGURATION
•Alias called @dev allows me to run remote commands
• $wp @dev cli info is different than $wp cli info
• @dev connects via SSH and runs on Vagrant box
https://make.wordpress.org/cli/handbook/config/
wp-cli.yml - Aliases with Vagrant
20.
21. CONFIGURATION
•Allows you to configure WP-CLI variables
•File can be at the Global, Project and Local levels
•e.g.: Local overrides Global
•Allows you to set up Aliases per site
https://make.wordpress.org/cli/handbook/config/
wp-cli.yml
29. INSTALL WORDPRESS
# Create Database for install
$wp db create wpcli-test
# Run the install process
$wp core install
—url=wpcli-test.dev —-title=“wpcli test”
—admin_user=admin --admin_password=password
--admin_email=info@example.com
30. INSTALL WORDPRESS
•Not needed if you’re using VVV
•WP installs can be created and provisioned via Vagrant
Note for VVV Users
https://varyingvagrantvagrants.org/
36. SHELL SCRIPTING
•You can use WP CLI with like any other command
•e.g. tie commands together and run them as a list
37. INSTALL WORDPRESS PLUGINS, THEME
#!/bin/bash
# list of plugins
plugins=("user-switching" "debug-objects""wp-cfm")
# loop through plugin list and install
for plugin in ${plugins[*]};
do
wp plugin install $plugin
wp plugin activate $plugin
done
56. CUSTOM SHELL COMMANDS
• functions can be created in your shell profile (.bash_profile) and
executed globaly
gen-content ()
{
wp any-ipsum generate-posts
wp comment generate --count=10
}
57. WP-CLI is a toolbox
Commands can be linked
together via scripts to
automate complex tasks