How To Teach PHP

While at PHP Appalachia, I had the pleasure of meeting David Rasch, the founder of Triangle PHP, which meets in the Raleigh-Durham-Chapel Hill region of North Carolina. One night, by the campfire, David and I launched into a discussion about how newbies learn PHP from current books on the market. He suggested that the format for teaching PHP needs to change and that these books need to start not by teaching PHP from the Web but by introducing newbies to PHP concepts by creating command-line applications. The idea being to introduce them early on to OOP and best practices, rather than trying to get them started fast with a simple “Hello, World” Web site.

While I agreed with the concept in general, I questioned the marketability of this approach. When a person picks up a book on PHP, I asked, what is it they want to do? The simple answer is: they want to create a dynamic Web site, and they want to do it now. Publishers will be very reluctant to publish a book that does not follow the traditional “teach them to create an application then teach them the best practices” model because the reader knows or has heard somewhere that PHP will enable and empower them to create an application – albeit a simple one – in a matter of minutes. This is what makes PHP so attractive to newcomers.

Nevertheless, David had some good points, and, while I was playing devil’s advocate in my comments, I agree that the way we introduce newbies to PHP needs to change at the fundamental level. Newbies must learn the fundamentals first, while still feeling like they are moving somewhere quickly and not being overburdened by a steep learning curve. Thus, David has followed up his original post with “Learning PHP sans bad habits,” which includes a proposed TOC for such a book. The proposed book introduces the reader to PHP syntax from the command line, but, by the second chapter, takes them into Web development with a simple framework that will protect them from bad practices (such as failing to filter input and escape output). At this point, the reader does not yet need to understand these principles or how the framework works (these are covered later in the book), but they are still learning how to protect themselves using best practices.

I think David’s got some good ideas here that the community should definitely take into consideration when teaching and writing books about PHP. Now, I’m just waiting to see what publisher will approach David first to turn his proposed TOC into a reality. ;-)