Troubleshooting and debugging errors in PHP
Dump, die, throw, log. In this hangout, we'll take a look at the various tools we have to help identify and troubleshoot errors in PHP as we design and develop websites and plugins with Craft CMS.
We take a look at various simple, dump-driven development techniques and then compare those to debugging in PhpStorm using X-debug. Brad Bell gives a demo on getting X-debug setup in PhpStorm along with several tips to improve your debugging workflow.
- 01:12 What steps should we take before we start troubleshooting in PHP? devMode, Server Info
- 05:45 Debugging slow queries with the console profiling section
- 06:12 What is in the Craft log files and how to do we find errors?
- 10:26 A look at the Craft::log() method in Craft and Plugins.
- 12:08 Where does Craft share information on PHP fatal errors?
- 12:58 Handling 404 errors
- 14:08 Dump-driven development: die, var_dump, print_r
- 15:54 Craft tools for dump-driven development: Craft::dump(), Craft::dd()
- 20:22 Preparing the request in the craft\app\etc\web\WebApp.php file
- 25:15 What is X-debug and where does it fit in?
- 26:38 How to setup X-debug to debug PHP in PhpStorm
- 31:19 A first look at debugging and some useful breakpoints to troubleshoot errors
- 35:00 Using X-debug to explore a saveEntry request
- 40:56 Using conditionals in X-debug to debug specific scenarios
- 45:45 Starting and stopping a debugging session in X-debug
- 48:21 Debugging different versions of PHP
- 50:28 Using X-debug to help debug a support ticket
- 1:06:35 Can we use X-debug to troubleshoot ajax requests too?
- 1:11:30 Wrap up