QueryPath in Practice: Migrating ICANN.org to Drupal

The Four Kitchens blog is running a story on how they used QueryPath and the Migrate module to migrate over 10,000 pages of content, in many different languages, into Drupal. I love to hear stories about the creative ways developers use QueryPath to accomplish complex tasks. A huge thanks to Mark Theunissen for the detailed write-up.

In related news, the new QueryPath 3 engine is just about done, and will make monster imports like this much faster.

The Architect and the Organism: What Plato and Aristotle have to say about Drupal

The video and slides for my DrupalCon Denver 2012 session are already available.

The slides and video can be found at the official site. Kudos to the DrupalCon Denver organizers, who are in the midst of running a fantastic conference.

PHP Stream Filters: Compress, transform, and transcode on the fly.

Your task: In PHP code, open a file compressed with BZ2, convert its contents from one character set to another, convert the entire contents to uppercase, run ROT-13 over it, and then write the output to another file. And do it as efficiently as possible.

Oh, and do it without any loops. Just for fun.

Actually, this task is exceptionally easy to do. Just make use of an often overlooked feature of PHP stream API: stream filters. Here's how.

PHP Mode Strings with Stat (and Stream Wrappers)

This article explains how to work with mode strings in stream wrappers, and in low-level calls to PHP's stat() functions. It will be helpful to those writing stream wrappers that must respond to functions like:

  • is_dir/is_file
  • file_exists
  • is_readable/is_writable
  • stat

Stream wrappers must supply the right stat arrays for these, and the most confusing value that must be set (for non-C programmers, at least) is the mode string.

I start off with a very basic intro to mode strings, and then dive down into the details of setting mode strings.

Removing trailing whitespace with VIM regular expressions

While cleaning up old sourcecode that I wrote with TextMate, I'm finding many cases where TextMate left trailing whitespace. To keep with current coding conventions, I am removing these extra spaces.

Here's a quick way to do this in VIM:

:%s/\s\+$//g

This tells VIM to search the entire document for lines that end with one or more whitespace characters. Any matching spaces will be removed.

Documenting PHP with Doxygen: The Pros and Cons

DoxygenDoxygenIt's been a few years, now, since I gave up using PHPDocumentor to document my PHP projects. I switched to Doxygen, an automated documentation tool that supports a wide variety of languages, including PHP. While PHPDocumentor enjoys broad support in the PHP community, Doxygen, too, is well entrenched. (Drupal uses it.)

I recently began a new project from scratch, and it gave me an opportunity to once again turn a hard gaze upon Doxygen. After some careful reflection on my experiences developing this new medium-sized library and documenting it with Doxygen, here are what I see as Doxygen's strong and weak points when it comes to PHP API documentation.

(Re)Mapping Command-Shift-Arrow Keys in Janus/MacVIM

Users of the Janus VIM suite may notice a change in the newest version of Janus. In previous versions, one could navigate around split panes (including to and from the file browser) by holding down COMMAND-SHIFT and then typing one of the arrow keys. This feature has been removed from the latest versions of Janus (I'm guessing because of some other conflict).

Here's how to add that back in.

  1. Open your ~/.vimrc.after file.
  2. Add the code shown below.
  3. Save and restart VIM.

Atoum: A Different Unit Testing Framework for PHP

For a long time, it has seemed that when it comes to unit testing in PHP, there is only one game in town: PHPUnit. And in all fairness, it's popularity is justified. It is a good framework, and can generally handle standard use cases.

But recently I found Atoum. Not being one to start small, I began using it on a large (soon to be Open Source) project that I was writing from scratch.

Was it love or infatuation?

Atoum has some great out-of-the-box features:

  • Support for PHP namespaces.
  • Each test can be run directly.
  • The CLI output is clean and intuitive.
  • I love the method chaining support.

Janus VIM on Linux Mint

VIM with JanusVIM with JanusLinux Mint claims to be the second most popular Linux distribution after Ubuntu. And it is largely based on Ubuntu/Debian. While there are many subtle differences, though, the main one is that Mint supports a broader range of desktop environments -- most notably, Gnome 3.

Janus is a package of tools that turn vanilla VIM into a powerful development environment. It is targeted at GUI versions (gvim and MacVim), and it comes with a large assortment of VIM plugins and scripts.

This short blog shows how to install Janus on a newly installed Linux Mint desktop. It assumes that you can run commands using sudo in a terminal.

Git drupal:// URLs for projects and sandboxes

In a previous post, I showed an example of cloning a module that included this command: git clone drupal://drupalcs. But I neglected to explain how this worked. I'm not sure where I picked this up (it was probably from Sam Boyer), but by adding a few lines to your ~/.gitconfig makes checking out Drupal projects and sandboxes easier:

[url "ssh://git@git.drupal.org/project/"]
    insteadOf = "drupal:"
[url "ssh://git@git.drupal.org/sandbox/"]
    insteadOf = "drupalsand:"

This allows you to use drupal://PROJECT_NAME to identify a project (module, theme) git repository, and drupalsand://USER/NID to checkout a sandbox. For example, I can clone one of my sandbox projects with this command, executed at the command line:

$ git clone drupalsand://mbutcher/1356522
Cloning into 1356522...
remote: Counting objects: 988, done.
remote: Compressing objects: 100% (466/466), done.
remote: Total 988 (delta 463), reused 878 (delta 404)
Receiving objects: 100% (988/988), 242.04 KiB | 354 KiB/s, done.
Resolving deltas: 100% (463/463), done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.

Perhaps this sort of syntactic sugar isn't for everyone, but I find it to be a nice configuration short-cut.

Syndicate content