PHP Hacks : Tips & Tools for Creating Dynamic Web Sites
- Author : Jack D. Herrington
- Paperback: 443 pages
- Publisher: O'Reilly Media (December 1, 2005)
- Language: English
- ISBN: 0596101392
- Product Dimensions: 9.0 x 6.2 x 1.2 inches
Programmers love its flexibility and speed; designers love its accessibility and convenience. When it comes to creating web sites, the PHP scripting language is truly a red-hot property. In fact, PHP is currently used on more than 19 million web sites, surpassing Microsoft's ASP .NET technology in popularity. Not surprisingly, this surge in usage has resulted in a number of PHP books hitting the market. Only one, though, takes the language beyond traditional Web programming and into mapping, graphing, multimedia, and beyond: PHP Hacks.
In PHP Hacks, author Jack Herrington wrings out his 20 years of code generation experience to deliver hands-on tools ranging from basic PHP and PEAR installation and scripting to advanced multimedia and database optimizing tricks.
On the practical side of things, PHP Hacks helps you develop more robust PHP applications by explaining how to improve your database design, automate application testing, and employ design patterns in your PHP scripts and classes. In the category of "cool," Herrington explains how to upgrade your Web interface through the creation of tabs, stickies, popups, and calendars. He even examines how to leverage maps and graphics in PHP. There's also a bounty of image and application hacks, including those that show you how to:
- Integrate web sites with Google maps and satellite imaging
- Dynamically display iPhoto libraries online
- Add IRC, SMS, and Instant Messaging capabilities to your Web applications
- Drop the latest Wikipedia dictionary onto your Sony PSP
- Render graphics and user interfaces with SVG, DHTML, and Ajax
Whether you're a newcomer or an expert, you'll find great value in PHP Hacks, the only PHP guide that offers something useful and fun for everyone.
Spotlight Reviews :
>> Reviewer: Robert L. Cochran (Greenbelt, MD USA)
I tried several of the hacks in this book and quickly scanned some others. It offers numerous ideas for dynamic web page presentation. Hack 11, "Put an Interactive Spreadsheet on Your Page", provides a fresh way to present tabular data in an Excel-like grid format, using a proprietary solution called ActiveWidgets. I downloaded the free version of the ActiveWidgets code and ran this hack. It is giving me ideas for how to present the kind of tabular data that might look good on a web page. At no cost, you can study a given bit of PHP code and decide for yourself if you can put it to further use.
I also tried Hack 10, "Send HTML Email". It works fine as stated, and for the first time I learned how to construct a multipart email. That is what prompted me to implement the hack, I have always wanted to do exactly this. I have some work to do with my sendmail mail transfer agent (MTA) software for this to work even better. The hack can be improved by showing how to avoid the problem of the MTA writing the wrong from and to email addresses and how to work around potential mail relaying issues. The bottom line, however, is that the code presented works as indicated.
I experimented with Hacks 4, "Build A Breadcrumb Trail", and 12, "Create Popup Hints". These work acceptably.
An exciting hack that I haven't tried yet is #44, "Scrape Web Pages For Data". I would like to use this one to scrape weather-related data from http://nws.noaa.gov/ for my zip code.
Another attention-getter are the hacks presented in Chapter 8, "Testing". I have not tried these hacks myself, but I think unit testing needs more attention in web pages that utilize heavy scripting, and I'll be sure to experiment with these hacks in two projects of my own that are currently ongoing. I definitely feel the need of automated testing.
Other good points about this book is that it offers hacks which cover graphics tricks such as implementing Scalable Vector Graphics (SVG). SVG deserves attention because the image renditions possible are stunning, and you can render them right now. Recent builds of Mozilla and Firefox support SVG natively and you do not need the Adobe plugin with these browsers. Author Herrington neglects to state this in Hack 28. When you see the graphical renditions you realize they are worth implementing in your PHP code.
I like the numerous screen shots the book provides. They offer a way to check my own results against what he suggests or shows are possible.
I would have given this book a 5 star rating if I had seen hacks that implement PHP Data Objects (PDO) with databases such as MySQL and SQLite. PDOs have been available in PHP for a long time now, I use them in most of my coding because they work so well and offer a cleaner interface to the database engine than the "traditional" PHP code taught in a lot of books. Likewise, there is a focus on PEAR programming, but in PHP version 6, which is now in development, there is no longer a default install of PEAR. Herrington also didn't test his Hacks code on different platforms. He appears to have settled on the Windows versions of Firefox 1.x, Apache server, and PHP. There is some reliance on Internet Explorer. I can see the results when I test his hacks in Mozilla and Firefox on the Linux OS. Indeed, it doesn't look like Herrington did extensive research for the book; otherwise he would have quickly learned that SVG is supported natively in Firefox. There is too much code printed, and not enough discussion about the code itself. I can download the example code easily enough; why print it at the expense of discussing it? The book index also needs improvement. You can see entries for "ActiveWidgets", for example, but not a related one for "widgets".
I ran all my tests of these hacks on Fedora Core 4 Linux, running MySQL 5.0.18, SQLite 3.2.x and higher, and development versions of PHP 6 available from http://snaps.php.net/ . I did not test these in Microsoft Windows XP.
This book belongs on your desk as you code PHP. I recommend studying it for the ideas it offers.
------------------------------------------------------------
>> Reviewer : Michael J. Ross
The book was published by O'Reilly Media in December of 2005. Despite its title, PHP Hacks: Tips & Tools for Creating Dynamic Websites is clearly intended to show how PHP's capabilities can be extended beyond its most common usage for creating dynamic and database-driven Web pages, and can be employed in such areas as graphics, reporting, Web site testing, code generation, and even fun purposes (for those few programmers who find the former topics less than entertaining). The author, assisted by six contributors listed in the Credits section, manages to pack an impressive number of general programming ideas and PHP-specific topics within this title's 468 pages. The material is grouped into 10 chapters, each of which contains a generous number of "hacks," each in its own section.
As with most if not all of the other titles published by O'Reilly, this book has a Web page that offers an overview of the book, its table of contents, all of the book's code (in both Zip and tar file format), and a list of confirmed and unconfirmed errata. In addition, the site hosts five sample hacks (in PDF format): accessing iPhoto pictures, generating Excel spreadsheets, avoiding the "double submit" problem, reading RSS feeds on your PSP, and creating custom Google Maps. Perusing these hacks would give the prospective buyer a clear sense as to the style of the book's other 95 hacks, as well as the (low) level of PHP expertise needed to understand them.
The book begins with a preface that describes the organization, conventions, and icons chosen for the book. Also, it covers the legality of the code samples, lists contact information, and mentions O'Reilly's Safari online book service, which contains this title among many other PHP resources. What is perhaps most unique about this book's preface is that the author identifies over half a dozen weaknesses commonly seen in PHP applications, and explains how his book addresses those problems. In addition, he makes explicit how some of the hacks can be used for jazzing up one's Web site or Web-based application.
The first chapter discusses how to install PHP on Windows, Mac OS X, and Linux, and then verify that the installation was done properly. Herrington then briefly explains how to install MySQL and perform some basic database management. The chapter concludes with coverage of installing the PEAR library on your local machine and on your Web host's server (which is incorrectly identified as your "ISP machine," apparently assuming that most developers choose their Internet service providers for hosting their sites, when in fact the opposite is true). Since the typical reader of a non-beginning book such as this no doubt has one or more introductory and/or reference PHP books at hand, it would seem superfluous to waste time and space explaining how to install these components. But few pages are taken up by the material.
The next chapter is devoted to hacks that help to jazz up the design of one's Web sites, including how to create a skinnable interface, build a breadcrumb trail, create HTML boxes, add tabs to your interface, and other valuable techniques. Subsequent chapters offer hacks in the areas of dynamic HTML (DHTML), graphics and digital pictures, databases and XML, application and e-commerce design, patterns and PHP object orientation, testing and documentation generation, and building alternative user interfaces. The 10th and final chapter covers some "fun stuff," such as creating dynamic playlists, developing a media upload/download center, and even putting Wikipedia on a Sony PlayStation Portable.
Rather than try to explain in detail all of the many topics covered in the book, I instead encourage the interested reader to visit the publisher's Web page, and scan through the table of contents provided, to get a better idea as to how much of the book would be of interest to the individual. Also, the five sample hacks listed on the site, would be well worth examining and trying out. Overall, the topics chosen reflect favorably upon the judgment of the lead author and the other contributors to the book. The typical PHP veteran would likely be interested in most of the applications covered, and would probably learn some new tricks, especially in the areas of patterns and code testing, regardless of their level of experience.
Like all books, this one is not perfect. As with the first printing of most technical books; particularly those chock-full of source code; the book contains a fair number of errata, likely even greater in number than those reported and listed on the publisher's Web site, as mentioned earlier. Consequently, any reader who chooses to test the sample code and he or she would be encouraged to do so; should keep one browser window or editor buffer open and devoted to those errata, so as to minimize the time spent trying to figure out why some sample code is not working as advertised.
Some readers posting in forums have complained that the sample code has evidently not been fully tested on all platforms, nor in all Web browsers. Since few if any reviewers would have the time, resources, or inclination to verify these claims, it should suffice to simply bear in mind that the script output and other behavior detailed in the book might not exactly match those experienced during one's own usage of the code.
The fact that there were several cooks in the kitchen brewing up this particular book, is obvious from the way that the code formatting is not consistent throughout the book, as well as the variety of problem-solving styles. Fortunately, neither weakness is of much consequence, and the latter might even be considered a "feature," as it allows the reader to see how a number of veteran PHP developers approach solving a problem.
Most technical works written by a team of authors, end up as excessive "doorstops" that are often frustrating to read as a result of the wildly inconsistent writing and coding styles, to say nothing of the material often being out of date as a result of the long production time needed by the publisher. The opposite case can be even worse, when a publisher releases a book that was clearly thrown together as quickly as possible to capitalize upon a hot new trend in technology. Thankfully, PHP Hacks keeps the style differences to a minimum, and benefits from having a lead author responsible for the book as a whole.
Some programming purists may take issue with the use of the term "hack" used as a synonym for a small PHP application or the use of such for solving a problem, since the majority of the PHP scripts in the book do not involve any programming or problem-solving that would be considered notably clever or elegant. Yet the misuse of the term seems to be spreading, and is not limited to this particular book ; another example of marketing overpowering stability of language. In the preface of PHP Hacks, the author explains that he uses the term in the positive sense of creative participation, to help reclaim it from its popular usage in place of the more traditional term "cracking," i.e., breaking into systems.
Yet aside from these complaints, PHP Hacks is a worthy title that offers explanations and source code for many valuable site-enhancing applications, testing and code generation techniques, and critical e-commerce safeguards. I recommend this book to any PHP developer who would like to add to their Web sites' capabilities, as well as their knowledge of what PHP can do.
Michael J. Ross is a freelance writer, computer consultant, and the editor of the free newsletter of PristinePlanet.com."
0 Comments:
Post a Comment
<< Home