To be successful at creating things, we have to be able to solve the problems we introduce along the way. Let’s learn to troubleshoot and debug issues!
We'll organize our approach to a problem by analyzing it, simplifying it, splitting it into its component parts, and finding what part has the problem.
After dividing the problem, we'll use classic debugging techniques to pinpoint the error and find a solution:
- Use a debugger like XDebug paired with PhpStorm or VS Code to step over and through key sections.
- Set breakpoints where we suspect the problem may lie or where we can inspect variables and data.
- Inspect the contents of the database to see what is happening there.
- Use old-school techniques like printf-debugging and calling die() to find where problems happen.
For extra credit, we'll take a look at how to use git bisect
to determine when a bug got introduced. We will talk about using tools and techniques, like version control and database snapshots, to assist in the problem-solving task. ChatGPT is bound to make a cameo as well.