Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hollywood WordPress - CLI For WordPress (an Introduction)

Hollywood WordPress - CLI For WordPress (an Introduction)

Presented by Mike Schroder at the Hollywood WordPress Meetup.

Introductory presentation on using the command line to make life easier for developers and designers alike.

Covers command line basics, followed by an introduction to WP-CLI for those who'd like to dig deeper and manage WordPress directly using the CLI.

Mike Schroder

July 10, 2013
Tweet

More Decks by Mike Schroder

Other Decks in Technology

Transcript

  1. CLI for WordPress
    an introduction
    Hollywood WordPress Meetup
    Mike Schroder (DH-Shredder)
    @GetSource - http://www.getsource.net

    View Slide

  2. Who Am I?
    • Mike Schroder, a.k.a DH-Shredder, a.k.a. @GetSource
    • Third Culture Kid, enjoy Coffee & Sailing
    • WordPress Core and wp-cli Contributor
    • Happy DreamHost Employee

    View Slide

  3. There are two groups
    of people.

    View Slide

  4. Those who use the
    command line

    View Slide

  5. Those who are going to use
    the command line

    View Slide

  6. Don’t be afraid of the CLI.
    It’s your friend.

    View Slide

  7. Oh, you like the CLI?
    wp-cli will make your life better.

    View Slide

  8. Command Line Interface:
    A direct, text-based, interface
    to a computer.

    View Slide

  9. A direct, text-based,
    interface to your server.

    View Slide

  10. At your host, you’ll see this
    referred to as SSH.

    View Slide

  11. Perform operations directly
    on your server.

    View Slide

  12. View Slide

  13. View Slide

  14. Why would I use the CLI?

    View Slide

  15. Efficiency!
    Get things done faster.

    View Slide

  16. Copying a WordPress
    install in SFTP?

    View Slide

  17. ~5 Minutes+

    View Slide

  18. Copying a WordPress
    install in SSH?

    View Slide

  19. ~10 Seconds

    View Slide

  20. What else can I do?

    View Slide

  21. Deploy your site.

    View Slide

  22. On-server file editing.

    View Slide

  23. Plugin and theme
    installation or updates.

    View Slide

  24. Commands and Arguments
    $ cmd [optional arg]

    View Slide

  25. Windows Instructions:
    - Install Putty: http://bit.ly/y99vUd

    View Slide

  26. View Slide

  27. Mac Instructions:
    Open Terminal, then:
    $ ssh [[email protected]]

    View Slide

  28. What are some basic
    commands?

    View Slide

  29. List files
    $ ls [-a] [location]
    -a for all files, including hidden

    View Slide

  30. Change directory
    $ cd
    Use ~ for home.
    ../ to go up a directory.

    View Slide

  31. Copy files
    $ cp [-r]
    -r copies recursively.

    View Slide

  32. Remove files
    $ rm [-r]
    -r removes recursively.

    View Slide

  33. Move files or directories
    $ mv

    View Slide

  34. Download files
    $ wget

    View Slide

  35. Unzip files
    $ unzip

    View Slide

  36. WordPress specific CLI
    operations: WP-CLI

    View Slide

  37. Super-cool Open Source tool
    to manage WordPress

    View Slide

  38. Headed up by
    Cristi Burcă (scribu) and
    Andreas Creten

    View Slide

  39. Uses WordPress itself to
    perform operations

    View Slide

  40. Automation!

    View Slide

  41. What can I do with it?

    View Slide

  42. View Slide

  43. No, Really.

    View Slide

  44. Update WordPress
    $ wp core update

    View Slide

  45. Install a Theme
    $ wp theme install

    View Slide

  46. Change Theme
    $ wp theme activate

    View Slide

  47. Backup your Database
    $ wp db export [filename]

    View Slide

  48. Update Plugins
    $ wp plugin update-all

    View Slide

  49. Update Themes
    $ wp theme update-all

    View Slide

  50. What do I need to run it?
    • SSH access to your WordPress install's directory
    • PHP 5.3+
    • WordPress 3.3+
    • Enough RAM for shell processes to run WordPress
    • Easiest on Linux & MacOS

    View Slide

  51. Okay. Got that covered.
    How can I get this
    Awesomeness?

    View Slide

  52. Install WP-CLI
    Full Instructions at http://wp-cli.org
    In short, from the root of your user:
    curl http://wp-cli.org/installer.sh | bash

    View Slide

  53. If you’re local and have sudo:
    sudo utils/dev-build

    View Slide

  54. Otherwise, add an alias
    (.bashrc/.bash_profile)
    alias wp='/home/user/wp-cli/src/bin/wp';

    View Slide

  55. In ~/.bash_profile:
    if [ -f ~/.bashrc ]; then
    source ~/.bashrc
    fi
    (http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html)

    View Slide

  56. You’ve got it installed?
    Let’s dig deeper.

    View Slide

  57. WP-CLI is extensible.

    View Slide

  58. Add your own directly
    wp-cli/php/commands/community/cmd_name.php

    View Slide

  59. Or, define in your plugins.
    if ( defined('WP_CLI') && WP_CLI ) {
    ! include( PLUGIN_DIR . '/lib/wp-cli.php' );
    }

    View Slide

  60. Sample Backup Plugin:
    http://getsource.net/2012/10/wp-cli-awesomeness-in-vancouver

    View Slide

  61. This is just a start.

    View Slide

  62. View Slide

  63. Resources!
    • http://wp-cli.org
    • http://files.fosswire.com/2007/08/fwunixref.pdf
    • http://getsource.net/2012/10/wp-cli-awesomeness-in-vancouver/
    • http://wp.tutsplus.com/tutorials/using-wp-cli-for-fun-and-profit/
    • http://halfelf.org/2012/command-line-wp/
    • http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html
    Mike Schroder (DH-Shredder)
    @GetSource - http://www.getsource.net

    View Slide