Interactive WordPress Debugging

A new command landed in WP-CLIWP-CLI WP-CLI is the Command Line Interface for WordPress, used to do administrative and development tasks in a programmatic way. The project page is a few days ago, called shell. It was inspired by an older project called wpshell.

When you run wp shell, a REPL will start, in which you can run any WordPress function.

The major advantage over wp eval and wp eval-file is that it’s interactive: you immediately see the result of the previous command; it’s also stored in the special $_ variable, which you can use in the next command and so on.

Here’s a contrived example session:

scribu@air:~/wp/core$ wp shell
Type "exit" to close session.
wp> get_bloginfo('wpurl')
wp> $_ . '/feed/'
wp> exit

wp shell will be available in the 0.7 release of WP-CLI, but if you want to try it out right now, clone the latest version from githubGitHub GitHub is a website that offers online implementation of git repositories that can easily be shared, copied and modified by other developers. Public repositories are free to host, private repositories require a paid subscription. GitHub introduced the concept of the ‘pull request’ where code changes done in branches by contributors can be reviewed and discussed before being merged be the repository owner. If you have suggestions for making it better, don’t hesitate to open issues and pull requests.