Save 37% off PRO during our Black Friday Sale! »

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.

46fa959634a063abefcac94eaf191eca?s=128

Mike Schroder

July 10, 2013
Tweet

Transcript

  1. CLI for WordPress an introduction Hollywood WordPress Meetup Mike Schroder

    (DH-Shredder) @GetSource - http://www.getsource.net
  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
  3. There are two groups of people.

  4. Those who use the command line

  5. Those who are going to use the command line

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

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

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

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

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

  11. Perform operations directly on your server.

  12. None
  13. None
  14. Why would I use the CLI?

  15. Efficiency! Get things done faster.

  16. Copying a WordPress install in SFTP?

  17. ~5 Minutes+

  18. Copying a WordPress install in SSH?

  19. ~10 Seconds

  20. What else can I do?

  21. Deploy your site.

  22. On-server file editing.

  23. Plugin and theme installation or updates.

  24. Commands and Arguments $ cmd <required arg> [optional arg]

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

  26. None
  27. Mac Instructions: Open Terminal, then: $ ssh [user@]<your_host_address>

  28. What are some basic commands?

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

    including hidden
  30. Change directory $ cd <location> Use ~ for home. ../

    to go up a directory.
  31. Copy files $ cp [-r] <source> <dest> -r copies recursively.

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

  33. Move files or directories $ mv <source> <dest>

  34. Download files $ wget <http://somesite/that.zip>

  35. Unzip files $ unzip <location.zip>

  36. WordPress specific CLI operations: WP-CLI

  37. Super-cool Open Source tool to manage WordPress

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

  39. Uses WordPress itself to perform operations

  40. Automation!

  41. What can I do with it?

  42. None
  43. No, Really.

  44. Update WordPress $ wp core update

  45. Install a Theme $ wp theme install <slug>

  46. Change Theme $ wp theme activate <slug>

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

  48. Update Plugins $ wp plugin update-all

  49. Update Themes $ wp theme update-all

  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
  51. Okay. Got that covered. How can I get this Awesomeness?

  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
  53. If you’re local and have sudo: sudo utils/dev-build

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

  55. In ~/.bash_profile: if [ -f ~/.bashrc ]; then source ~/.bashrc

    fi (http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html)
  56. You’ve got it installed? Let’s dig deeper.

  57. WP-CLI is extensible.

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

  59. Or, define in your plugins. if ( defined('WP_CLI') && WP_CLI

    ) { ! include( PLUGIN_DIR . '/lib/wp-cli.php' ); }
  60. Sample Backup Plugin: http://getsource.net/2012/10/wp-cli-awesomeness-in-vancouver

  61. This is just a start.

  62. None
  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