PHP

Book review: Beginning Ajax with PHP by Lee Babin

Book Review
Apress: Beginning Ajax with PHP by Lee Babin

Book Site | Sample Chapter: 3 PHP and Ajax | Table of Contents

Although no stranger to Ajax, I received a review copy of Beginning Ajax with PHP expecting some watered down presentation of Javascript with some PHP thrown in. I was quite surprised to find a good presentation of using Ajax and PHP, easy enough for the beginner and still interesting for those who have done it for years.

The book starts out exactly how I would write it -- SIMPLE! The first time I did Ajax with XHR (xml http request), I used a plain text file, which I then read into a DIV at the click of a link. This takes a similar approach and has data stored in an array which is then accessed with a simple call to a PHP file. The following chapter, takes it a step further and this building upon previous chapters is a common theme in the book.

Book Review: PHP Hacks

Book Review: PHP Hacks by Jack D. Herrington, published by O'Reilly

I had borrowed a Perl Hacks book from and friend and really liked it, it was great! It had a lot of practical things as well as some fun things. I expected the same from PHP Hacks and I was not disappointed!

Here’s the table of contents: http://www.oreilly.com/catalog/phphks/toc.html

O’Reilly also has some sample hacks: http://www.oreilly.com/catalog/phphks/chapter/index.html

Here's some that I found interesting:

The Practical Stuff

Breadcrumbs
Not familiar with the term? Check it out. I think this hack may get you started on a breadcrumb function/method. In the end they suggest a xml file to show which page urls were parents of which. The way I've done this before was I had a class for each major section, and sub section, and had a method ->addCrumb($label, $url) which I had in the constructor…and the subsections of course would call the parent contructor and it kept the breadcrumb hierarchy intact. But hey, that’s the fun of programming - different ways to do the same thing to meet different needs! Definitely a good hack to get the juices flowing!

The Joy of Regular Expressions

Following on from the last part, this one is more of an intermission—a round up of regex syntax seen so far and a couple of links following feedback.

First you have to check out Andrei’s Regex Clinic (slides / pdf)—even if you don’t get it all, it’s worth it for the pictures at the start ;) That’s Andrei as in Zmievski, as in works at Yahoo, can be blamed for Smarty and PHP-GTK, is one of those who needs thanking when PHP6 (with Unicode) hits the streets and, long ago, even did an interview with Sitepoint.

Andrei’s talk also prompts me to confession: I’m not qualified to tell you about the theory behind regular expressions (if you’re interested, start here and Google for more—or annoy these guys)—I’m coming from a practical perspective so while these blogs will (hopefully) help you discover regexes as a useful tool, don’t expect to find out how to to write your own regex engine.

PHP extension for Cairo graphics library

Thanks to tip off from Jared “Ren” Williams (is that you?—any link?) here—the Cairo wrapper extension by Hartmut Holzgraefenice demo.

Cairo is the “next generation” vector graphics library for Linux and very cool to have it available in PHP. Also cool about the extension was created using PEAR::CodeGen_PECL, which Hartmut describes here: look Mum—no C! (well almost).

Flickr mySQL DBA Blog

Quick note—Dathan Pattishall, one of Flickr’s db / software engineers has been dropping notes on his new blog mySQL DBA—some fascinating insight and technical tips.

Related to recent UTF-8 discussions

Will update the wiki in due course.

Personality Obsessions of Software Developers

Rob Walling managed to generate a lot of interest in writing Personality Traits of the Best Software Developers. While I vaguely agree with Rob’s points, at some level reading it produces a feeling which I can only compare to finding a fingernail in your sandwich.

Approaching 10…

On this “perfect developer” profile, strikes me there are a couple of missing points (for starters!). Based on my own flawed view of things…

  • Is passionate about what they do. Let’s face it—staring at a monitor for 8+ hours a day ain’t Rock N’ Roll (well for most of us anyway)—at some fundamental level you have to enjoy doing this stuff. Put another way—I’d rather work with a passionate trainee than a bored veteran.
  • Has some humility. Being “wrong” is inevitable—you will write code that has bugs, you will produce suboptimal designs and you’re not an expert on everything—how would Linus fare with CSS? If you can’t admit you’re in the wrong, there’s little space to fix problems, learn from mistakes plus you’re probably hard to work with. Inverting this—between binary 0 and 1, there’s no room for ego. The danger, given you’re spending a fair chunk of your life at the keyboard, is your perceived self-worth becomes attached to your ability to hack—an affront to your code becomes a deeply personal attack…

More nit-picking in detail…

DC PHP Conference Call for Presenters

If you're considering submitting, don't forget that today is the deadline:

Call for Presenters!

Building Clean URLs Into a Site

I wrote about building a site with clean URLs, but that's useless to you. No, you've got a creaking hulking monster of a site that coughs up URLs like "render.php?action=list_mailbox&id=42189", was built "to meet an accelerated schedule", and eats summer interns whole.

This article tells you how to put clean and human-usable URLs on top of the site without even editing your underlying scripts. All these examples mention PHP but it doesn't matter what you coded the site in, you just have to be running Apache and have a little familiarity with regular expressions.

So we have two goals. First, requests for the new URL are internally rewritten to call the existing scripts without users ever knowing they exist. Second, requests for the old URLs get a 301 redirect to the new URLs so that search engines and good bookmarks immediately switch to the new URLs.

Let's work through an example .htaccess file. We take apart the new URLs and map them internally to the old URLs:

The Underground PHP and Oracle manual

Chris Jones just announced the publication of the PHP and Oracle Manual (PDF) and from a high speed eyeballing, it’s good—basically tells you everything you need to know to be able to do useful stuff with PHP + Oracle but with little assumed knowledge.

In fact it seems to be geared to the typical LAMP developer—for example there’s a section on “Installing Oracle XE on Debian, Ubuntu and Kubuntu” plus sections on “Limiting Rows and Creating Paged Datasets” and “Auto-Increment Columns” show an awareness that readers will probably have MySQL experience.

Perhaps one addendum (I didn’t find reference to it) would be pointing readers at SQL Developer, which is a fairly new, free offering from Oracle as a desktop based development tool—the Underground manual focuses on a web based interface to Oracle—something logically equivalent to phpMyAdmin and a good starting point I guess but if you have to do real work, SQL Developer is probably a better choice.

Ajax Back, Forward, Reload and PHP

IdaAshley writes "A major challenge of Asynchronous JavaScript and XML (Ajax)-driven Web sites is the lack of a Back button. Mike Brittain discusses ways to get around this obstacle in part 1 of the 'Developing PHP the Ajax way' series." From the article: "The Web is a page-by-page medium. The backward and forward buttons on your browser's toolbar direct the browser from page to page. When Macromedia's Flash became all of the rage, developers and users started to see how Rich Internet Applications (RIAs) break this metaphor. You might click around a few sites, land on a Flash-based Web site, then click around in it for a few minutes. One click of the Back button and the ride is over. Rather than going one step backward within the Flash site, you completely lose your place."