Shane Dowling : 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.


  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
  6. Install FireBug and FirePHP on firefox and enable the Net Panel in firebug


  1. Checkout watchdog output on firePHP, pretty cool eh?
  2. You can see queries in the sidebar or if you're logging them, here
  3. Directly output to firephp with(alternate WARN with ERROR or INFO):

dfb($foo, 'probably bad', FirePHP::WARN);

Drupal Specific Vim Config


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

:SauceNew drupal

then edit it with

:SauceEdit drupal

Drupal Vimrc

This project provides vimrc customisations for Drupal-specific editing. Exactly what

drush @none dl vimrc

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.

set nocompatible call pathogen#infect('/home/user/.drush/vimrc/bundle') call pathogen#infect('/home/user/.vimsauce/drupal/bundle') " End of vimrc-install additions.

let g:current_dir = "~/code/drupal" exec 'cd ' . g:current_dir

" Allow Vim-only settings even if they break vi keybindings. set nocompatible

" Enable filetype detection filetype plugin on

" General settings set incsearch "Find as you type set scrolloff=2 "Number of lines to keep above/below cursor set number "Show line numbers set wildmode=longest,list "Complete longest string, then list alternatives set pastetoggle= "Toggle paste mode set fileformats=unix "Use Unix line endings set history=300 "Number of commands to remember set showmode "Show whether in Visual, Replace, or Insert Mode set showmatch "Show matching brackets/parentheses set backspace=2 "Use standard backspace behavior set hlsearch "Highlight matches in search set ruler "Show line and column number set formatoptions=1 "Don't wrap text after a one-letter word set linebreak "Break lines when appropriate

" Persistent Undo (vim 7.3 and later) if exists('&undofile') && !&undofile set undodir=~/.vim_runtime/undodir set undofile endif

" Enable syntax highlighting if &t_Co > 1 syntax enable endif syntax on

" Custom key mapping map :redo map :tabn map :tabp

" Uncomment the following to have Vim jump to the last position when " reopening a file if has("autocmd") au BufReadPost * if line("'"") > 0 && line("'"") <= line("$") | exe "normal! g'"" | endif endif

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.

sudo pear install PHP_CodeSniffer

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

sudo ln -sv ~/.drush/drupalcs/Drupal $(pear config-getphp_dir)/PHP/CodeSniffer/Standards

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

Use drupals codesniffer

let g:syntastic_phpcs_conf=" — standard=Drupal — extensions=php,module,inc,install,test,profile,theme"

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.

sudo phpcs — config-set default_standard Drupal

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.

call system("sudo phpcs — config-set default_standard Drupal")

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.