Archive for the ‘At Work’ Category

Six PHP Essentials You Can’t Live Without

Monday, March 19th, 2007

PHP, or PHP: Hypertext Preprocessor, is a versatile Web programming language that stands behind some of the world’s largest Web sites. While the designers of the language have been the target of criticism pertaining to both security and usability, PHP has nonetheless evolved into one of the most extensible and popular languages powering the Web today.

Here are six of the PHP classes, extensions, and libraries that no developer should be forced to live without!

ADOdb

http://adodb.sourceforge.net/

For development work that involves the use of a database, ADOdb is a must. This fast, mature, and portable database abstraction library provides much needed coherence, especially for those who have standardized on PHP 4. ADOdb includes support for MS SQL, MySQL, Oracle, and PostgreSQL, among many others.

Tip: Replace the standard MySQL functions in PHP 4 with ADOdb. You’ll thank yourself later.

Mcrypt and Mhash

http://www.php.net/mcrypt and http://www.php.net/mhash

These interfaces, which I’ve decided to present collectively, provide excellent support for strong encryption and various hash algorithms through Mcrypt and Mhash. Although both extensions were technically included with PHP until version 5.3.0, many installations of PHP are compiled without support for them, and relatively few users seem to be aware that these outstanding development tools exist.

Tip: Use these extensions to easily replace several broken or obsolete algorithms that are supported natively by PHP.

PHP-Imagick

http://pecl.php.net/package/imagick

It’s no secret to many PHP developers that the integrated support for GD has a number of serious limitations. ImageMagick is frequently regarded as the most comprehensive and powerful image manipulation suite, but many PHP developers are unaware that support exists for it. As it turns out, an extension by the name of PHP-Imagick provides an excellent alternative to the integrated GD functions.

Tip: Use PHP-Imagick to avoid roadblocks — for example, lossy thumbnails — when working with high resolution images.

PHPMailer

http://phpmailer.sourceforge.net/

As far as the mail() function is concerned, “quirky” is a vast understatement. Many critics and developers alike would argue that PHP allows you just enough rope to hang yourself and your users.

Fortunately, an alternative e-mail class exists in the form of PHPMailer, and it provides very clean, refined support for electronic mail. Its feature set includes SMTP redundancy, SMTP authentication, support for HTML, support for embedded images, and much more.

Tip: Combine PHPMailer with Smarty (see below) for a powerful e-mail template system.

SAJAX

http://www.modernmethod.com/sajax/

AJAX, short for Asynchronous JavaScript and XML, is a buzzword that describes a method by which interactive Web applications are created. It takes advantage of the XMLHttpRequest object, which allows an application to push or request content without refreshing the page.

Due to small variations in how the XMLHttpRequest object has been implemented by the various browser manufacturers, it can be tedious and time-consuming to roll your own AJAX implementation. Fortunately, SAJAX provides a straightforward framework upon which to build an AJAX application, saving precious development time.

Tip: Keep in mind that there are caveats to AJAX. For example, it’s easy to break browser navigation or make your application inaccessible to search engine spiders, so use it with caution.

Smarty

http://smarty.php.net/

It’s always best to separate your code from your content. Smarty, one of the best template engines for PHP, is built to serve that purpose, as well as many others.

It provides an excellent framework upon which to standardize your templates. Additionally, with its advanced support for caching, Smarty often proves itself more efficient than the competition. If you’re thinking about rolling out your own template engine, consider saving yourself some time by adopting Smarty.

Mobility in the Information Age

Friday, March 16th, 2007

I’ve had quite a number of people ask me how I manage to stay connected, despite my ostensible addiction to traveling. I am, for example, writing this particular article as I sit in the strikingly rustic lobby of a Marriott resort near Austin. Just 15 years ago, what I’m doing today wouldn’t have been possible. Of course, technology has changed dramatically since then, and it is now possible to remain attached to the real world from any place you might decide to roam.

If you’re a serious traveler, then it’s a good idea to own a seriously mobile laptop computer. Japanese imports, especially those svelte gadgets offered by companies like Dynamism, are usually the best suited for this purpose. My personal laptop is an ultralight Sony TX series, which weighs in at well under three pounds and follows me almost everywhere I go. It comes with the added benefit of having a ten hour battery life, making it especially useful in the car, on a plane, or anywhere else an electrical connection might not be available.

But what good is a mobile computer without an Internet connection? Despite the fact that almost any laptop built today is going to have support for 802.11b/g/n (i.e., Wi-Fi) connectivity, there isn’t a Starbucks on every street corner just yet, and public networks are still relatively scarce in rural areas. As a result, a large number of wireless providers are now offering mobile broadband cards that can be used in conjunction with your laptop computer. An unlimited access plan usually runs about $50 per month, and provides you with near-broadband connectivity. There is one caveat: Latency, sometimes over 500 ms, will prevent you from playing certain video games or using services (SSH, for example) that mandate a low-latency connection.

In addition to my laptop computer, I also carry a Palm Treo smartphone, which allows me to accept calls and read new e-mail while I’m on the road. In addition, my bundled data plan offers unlimited Internet connectivity, which I sometimes use to check my favorite Web sites. The Treo can also be used as a wireless modem (see PdaNet) with some carriers, removing the need altogether for a mobile broadband card. It should be noted that this gadget still has a number of show stopping problems, however, and should not be depended on as a universally reliable device.

The availability of this technology might prompt you with one final question. Do you want the real world to follow you on your travels? While some people — myself included, apparently — don’t seem to mind it, others still do. If you think that you might be one of those people, then it could be best to simply disconnect and enjoy life.