Making Drupal 6 Development Suck Less

So you’re here. Like myself probably stuck developing for Drupal 6. All the modules on-line are for the latest and greatest versions of Drupal and you’re scouring posts from 2009 to try find that deprecated module you really need. Well his post is dedicated to making your life that little bit less painful, because I too feel your pain.

Better debugging with devel

Installation

  1. Install subversion(to allow devel to download the firePHP extension code needed).

  2. Make sure drush is installed.

  3. drush dl devel && drush en devel

  4. Enable user permissions for devel

  5. Enable what you need to at http://root_url.com/admin/settings/devel

  6. Install FireBug and FirePHP on firefox and enable the Net Panel in firebug

Usage

  1. Checkout watchdog output on firePHP, pretty cool eh?

  2. You can see queries in the sidebar or if you’re logging them, here http://example.com/devel/queries

  3. Directly output to firephp with(alternate WARN with ERROR or INFO):

Drupal Specific Vim Config

VimSauce

I like to keep my vim configurations separate from each other so I don’t end up with huge messy config files with settings overlapping and breaking things. Before I used some shell aliases to alter symlinks to different vim configurations I had. Now, I use vimsauce to manage them. Once you got VimSauce installed(I’d recommend Vundle) create a new Drupal specific sauce with

then edit it with

Drupal Vimrc This project provides vimrc customisations for Drupal-specific editing. Exactly what we need. To install using drush run this:

This should install the file into ~/.drush/vimrc/bundle. Now you need to configure your new vimsauce file to work with the drupal vimrc customisations. The vimrc below should explain things. It’s a merge of the vimsauce default settings, a file I found under ~/.drush/vimrc/examples/vimrc_timplunkett.vim and the pathogen settings.

Sticking to a Coding Standard

So I try to always adhere to the coding standard of whatever system I’m using. Typically that’s easy but I’ve found getting my hands on a automated check that ensures my code is up to drupal’s standards a little difficult(especially with drupal 6). Firstly you need to install PHP’s codesniffer, which I did using PEAR.

In the end I was forced to use a Drupal 7 specific codesniffer. This project has actually been merged into the Coder project but as I’m using Drupal 6, the current version of coder that works with Drupal 6 doesn’t include the codesniffer. So I nabbed the latest standalone version of drupal codesniffer.

I then extract it to my ~/.drush folder and symlink it to where pear has placed php codesniffers various syntax checking config files

Now, this is the setting that I’ve come across that apparently changes phpcs to use Drupal as the standard which codesniffer adheres to.

I could not get this to work. It simply refused to budge from the standard PSR syntax checker that is the default for PHP codesniffer. I was forced to just set the default to drupal’s.

This is a little annoying if you jump between standard PHP projects and Drupal projects, so I added a system command call to my various vim sauces to set php codesniffer to the correct standard. It should bug you to enter a sudo password, but I’d rather that than having to explicitly run these commands.

This post has already gotten very long but I’ll try to write something up on getting unit-testing up and running with Drupal 6 at a later stage. I can attest it is possible, just a bit of a pain in the ass.