Jump to content


Check out our Community Blogs





- - - - -

Book Review: Php Ajax Cookbook

Posted by WingedPanther73, 08 April 2012 · 2878 views

I recently finished reading my first "cookbook" style programming book: PHP Ajax Cookbook: http://www.packtpub....0-cookbook/book . This is my first cookbook review, so I thought I'd start by clarifying what this is and is not. It is not a textbook-style book, similar to "Learn Ajax in 21 days". It is also not a reference book that you can sit on your bookshelf and pull down when you need to look something up. It's a survey of a wide variety of basic techniques that can be implemented with Ajax techniques and how they're done. You should be familiar with both PHP, JavaScript, and CSS before picking this up, or you will get REALLY lost.

With that said, I thoroughly enjoyed this book. I recommend going ahead and downloading the source code files (there's a registration, but it's painless). Some examples are fairly lengthy, and you'll want the source code handy. In fact, this book is between 30% and 50% code!

The layout of the book is chapter around a main concept. Each chapter has several sections, each devoted to a single example. For every example, several things are provided: an overview of what the goal is, the code to implement a simple example (enough for you to build a real-world product), an explanation of how it works, often nearly line-by-line, and a "There's more..." section that gives you additional resources and ideas.

Chapter 1 gives you a quick orientation to JavaScript libraries that will make doing Ajax a lot easier. The practical examples will give you a sense of the style of jQuery, Ext JS, MochiKit, Dojo, YIU, MooTools, and prototype.js. You'll have to learn them on your own, but you will get a sense of how they work, and what they're like. The authors use jQuery for the rest of the book. It's worth using one of these libraries, because raw JavaScript makes doing Ajax calls awkward. The elegance these provide for coding is worth the effort.

Chapter 2 goes over basic Ajaxy things. Form validation (really just jQuery form validation), autosuggest (similar to Google's search), creating a multi-step form wizard, file updload, multi-file upload using Ajax + Flash, implementing a 5-star rating system, etc. The purpose of this chapter is to expose you to how easy Ajax effects are to implement. It's generally a simple combination of CSS and small bits of jQuery that have a powerful effect.

Chapter 3 looks heavily at the extensions that are available for jQuery. Often there are several options (with links provided) of which one is chosen for demonstration purposes. If you're interested in using jQuery, this chapter will provide you with a wealth of resources to give you ideas for cool things you can do. Examples include an image slider, a Lightbox image loader, a shopping cart, and data sorting/filtering.

Chapter 4 pushes this further, showing how to create a chat system and how to decode a simple CAPTCHA using the HTML5 canvas element. These examples are very detailed and will give you a solid idea of the power that is present. One of the key things you will learn is how to do this without using excessive Ajax calls. You can easily kill a server's bandwidth with the "obvious" solution. Thi shows you how to avoid that.

Chapter 5 goes in a completely different direction: debugging. It discusses using Firebug and FirePHP, including the details of how to set both up, in Firefox. It discusses the IE developer toolbar. Memory leaks are dealt with in detail, as are how to deal with various timing issues that can crop up. If you've done PHP/HTML/JavaScript debugging, you already know how annoying this can be. I picked up several tricks, and I thought I was Firebug-savvy!

Chapter 6 discusses optimization issues, including the use of Yslow. It's very easy to make an Ajax site that works poorly, so these tips will help a lot. It discusses where to place sections of code, caching concerns, etc. Most of these are tips you can find in numerous other sites, but they are nicely consolidated, here.

Chapter 7 discusses other best practices, including security concerns and how to address SEO concerns when dealing with dynamic content. Having SEO friendly content means having static content with fixed URL's for each content item. Having Ajaxy content is basically the opposite. This chapter has numerous tips on how to satisfy both requirements, so users can easily find your content.

Chapter 8 discusses ways to use various services that have API's, such as Flickr, Twitter, and Google Maps. These are techniques that can make a website "pop", such as getting a list of nearby restaurants with a map, a customized twitter feed, or image search. As usual, you won't learn the full API, but you will learn the basic techniques for leveraging these APIs on your own site.

Chapter 9 was the most surprising for me. Building iPhone apps using html, Ajax, and PhoneGap. It can also be used for building Android apps, but the authors focused on the iPhone. PhoneGap is a tool that lets you compile an HTML/Ajax page into a native app for the iPhone, Android, etc. It's a tool I'd never heard of, but offers a huge amount of options for the mobile development market.

I enjoyed the book. There's a TON of information here, and the timing was ideal, as I'll be designing a new PHP/Ajax app for my job at work. Topics range from basics of using a framework, to quality layouts, to security concerns. The details will be found elsewhere, but the core ideas are all in here.

  • 1



I have enjoyed reading your reviews as always. I would consider it a steal at $22 for the ebook as a quick look in to what you can do with AJAX. May pick up a copy in a few months time to read and lend to people who are interested in pratical code examples.
    • 0
I believe you can get the source code without having the book. That should give you a good idea of the general content, then get the book for explanations and download links for libraries.
    • 0
Is this the one:
http://www.amazon.co...k/dp/1849513082
I might purchase it but $20 seems a bit much. How lengthy is it (obviously 340 pages but in your opinion how much content did it have)?
    • 0
To me, it was definitely worth $20. Most of my coding books cost $40-$60, though, so you may want to consider that in my assessment.
    • 0

To me, it was definitely worth $20. Most of my coding books cost $40-$60, though, so you may want to consider that in my assessment.


You're an author? I know some instructors write their own books for their classes.
    • 0

Most of my purchased coding books cost $40-$60. I might become an author, but it'll be sci-fi/fantasy :)

    • 0
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download