Introduction to WP-CLI

Introduction to WP-CLI

50f2fd7aa44542a8fec5128352ed5a45?s=128

Kyle B. Johnson

November 02, 2017
Tweet

Transcript

  1. 2.

    $ wp plugin install ninja-forms Installing Ninja Forms (3.0) Downloading

    install package... Unpacking the package... Installing the plugin... Plugin installed successfully. Success: Installed 1 of 1 plugins.
  2. 3.

    $ wp core download Downloading WordPress 4.8 Md5 hash verified:

    c5366d0521831dd029dfc38e56a5 Success: WordPress downloaded.
  3. 5.

    $ wp plugin update Updating to version 4.9 Downloading update...

    Unpacking the update... Success: WordPress updated successfully.
  4. 7.

    Example Use Cases • Plugin/Theme Development • Local Development Environments

    • Client Site Maintenance • WordPress as a Service
  5. 9.

    Local Development Environments • Download/Install/Update WordPress • Auto install plugins/themes

    • Search/Replace database values (site migration) • Launch PHP’s built-in web server $ wp serve –-host=wordpress.dev ~/code/wordpress now available at wordpress.dev:80
  6. 10.

    Client Site Maintenance • Remotely Update WordPress (SSH) • Check

    for plugin updates • Restore down sites (white-screen of death) $ wp plugin deactivate <plugin name> --skip-plugins Success: Plugin <plugin name> deactivated.
  7. 11.

    WordPress as a Service • Check for updates • Create

    user accounts • Create new installs $ wp site create --slug=example Success: Site 3 created. wordpress.dev/example
  8. 13.

    $ wp ninja-forms list-forms public function list_forms( $args, $assoc_args )

    { foreach( Ninja_Forms()->forms() as $form ){ WP_CLI::line( ‘#’ . $form[‘title’] ); } }
  9. 15.

    Laravel $ artisan # Generate a new controller. $ artisan

    make:controller PostController # Re-run database migration with seed data. $ artisan migrate:refresh --seeds
  10. 16.

    Drupal $ drush # Run pending updates on staging site.

    $ drush @staging updatedb # Synchronize staging files to production. $ drush rsync @staging @ list