Chapter 17. Debugging PHP

Debugging is an acquired skill. As is often said in the development world, “You are given all the rope you should ever need; just attempt to tie a pretty bow with it rather than getting yourself hanged.” It naturally stands to reason that the more debugging you do, the more proficient you will become. Of course, you will also get some excellent hints from your server environment when your code does not deliver what you were expecting. Before we get too deep into debugging concepts, however, we need to look at the bigger picture and discuss these programming environments. Every development shop has its own setup and its own way of doing things, so what we’ll be covering here reflects the ideal conditions, also known as best practices.

PHP development in a utopian world has at least three separate environments in which work is being done: development, staging, and production. We’ll explore each in turn in the following sections.

The Development Environment

The development environment is a place where the raw code is created without fear of server crashes or peer ridicule. This should be a place where concepts and theories are proven or disproven, where code can be created experimentally. Therefore, the error-reporting environmental feedback should be as verbose as possible. All error reporting should be logged and at the same time also sent to the output device (the browser). All warnings should be as sensitive and descriptive as possible.

Note

Later in ...

Get Programming PHP, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.