From the course: Advanced PHP: Debugging Techniques

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

WordPress CLI shell

WordPress CLI shell

- Local debugging can sometimes mean interactively trying out things. We can use WP-CLI Shell and interactively test code, either before adding to the code base, or to confirm a bug. Now you're probably wondering why WP Shell and not PHP-a . WP Shell loads WordPress up to the point that plugins and themes are loaded. Here we can see that the init action has run. We have the entire WP application available to us. This can be a ton of data, but it's also helpful to think about all the things that are specific as to why we are using the shell. Some quick highlights on how we interact with the shell. First, if you type incorrect syntax, it's game over. But when you drop back into the shell, it's like bash. Your commands are still there. We can hit the Up Arrow to scroll back to previously run commands. Once we fix the command, we see the output looks a lot like a var dump. You can do things like access the WPDB global…

Contents