If you have access to WP CLI I can’t recommend it enough. Since I picked it up it has saved me so much time during development. It helps me scaffold code, analyse the installation, update core and plugins, and it even helps me test code on the fly.
wp shell
The wp shell
command is frickin’ sweet as, bro!
You pump it into your command line and voila, you are in an interactive shell with your WordPress environment all loaded up. From here you can invoke any functions loaded up by WordPress, plugins, or your theme, not to mention all of PHP’s built-in functionality. You can even assign variables, write functions, and run expressions you are used to writing in PHP.
It is a fantastic way to test and check your code and I often find myself using it to test whether a function is going to do what I need or if some combination of, say, array functions will result in what I’m thinking they will.
If you change your code in any way, you need to exit
and then run wp shell
again as your code changes won’t be picked up until you do.