Drupal 8: Autoloading Basics

Autoloading of PHP classes was introduced in Drupal 7. Through a mechanism known as "the registry", modules were able to specify the files that contained their class definitions, then simply use the classes without needing a require or include statement. This system definitely isn't perfect... Having a database backed registry caused a lot of queries for modules like Views that instantiate a lot of classes. It also required a cache clear to pick up any caches, and forced developers to maintain an explicit list of their classes, which then had to be parsed and scanned each time caches were cleared.

Meanwhile, in the broader PHP world, a system known as PSR-0 was conceived. PSR-0 is able to autoload classes with minimal explicit registration, and has no dependency on the database. Because it is a PHP standard (rather than a Drupal specific standard), you can also count on broad support for your favorite external libraries.

Tokens in Drupal 7

This article is a followup to Creating Tokens in Drupal 6. Part of the token module was moved into core for Drupal 7, meaning it is even easier to create and use tokens programatically. I'm going to walk through how to use tokens programatically in Drupal 7, both using existing tokens and creating new ones.

Fast Drupal on Linode

I recently made the switch from Hostgator Shared hosting to a Linode instance, and WOW. It's amazing what you can do with a single (relatively small) box dedicated to serving up a single site. Without any further ado, I want to share some tips I gathered from setting the server up, and some benchmark results from along the way.

Using Drupal's Queue API

One of the additions to Drupal 7 that went in without a lot of fanfare was the Queue API. The Queue API is designed to manage tasks. It's very similar to the way we make to-do lists for household chores. If you have a hundred things to do in a day, you need to write them down and cross them off the list as you do them. Otherwise you lose track of what's left.

Easy Upgrade to Drupal 7

If there's one thing I've learned about upgrading Drupal sites, it's that you're going to have to do the same 50 steps over and over and over again to fix things as they fail. It's awful, tedious work.  Luckily, Drush now has "drush site-upgrade," which makes things considerably easier.  Still it ignores a couple of the really fundamental things like making sure your existing Drupal 6 site is up to date before it starts, and copying the files directory over to your new site.  So I wrote a shell script to do all of this for me.  

Browser Signature Pad

With the rise of web applications, the web browser is being used for stuff that used to take a complex piece of software on the local computer. For example, UberPOS is a project I've been working on recently that brings a point-of sale cash register to any computer capable of connecting to the internet.

Custom Submenus for Drupal

Creating Tokens in Drupal 6

Update 8/13/11 - For creating tokens in Drupal 7, see Tokens in Drupal 7.

Subscribe to RSS - Drupal