drupal

20 Jun

Pronto.js: How ConsumerSearch's Mobile API Server is Driven by Node.js

in drupal, fortissimo, javascript, node.js, php, programming, pronto

I was thrilled to read the story at Mobile Drupal about how ConsumerSearch is using Pronto.js to expose their huge Drupal content to their mobile application.

Pronto.js is designed to be a high performance asynchronous application framework that makes it simple to chain together components to build sophisticated application logic. It's the JS equivalent of the PHP Fortissimo framework.

18 Jun

Connection Sharing with CURL in PHP: How to re-use HTTP connections to knock 70% off REST network time.

in curl, drupal, hpcloud, performance, php, programming

The PHP CURL library is the most robust library for working with HTTP (and other protocols) from within PHP. As a maintainer of the HPCloud-PHP library, which makes extensive use of REST services, I've been tinkering around with ways of speeding up REST interactions.

What I've found is a way to cut off nearly 70% of the processing time for a typical usage scenario. For example, our unit tests used to take four minutes to run, and we're now down to just over a minute, while our Drupal module's network time has been cut by over 75%.

This article explains how we accomplished this with a surprisingly simple (and counter-intuitive) modification.

19 May

Updated Instructions for Installing Drupal Vagrant on Windows 7

in drupal, git, multi-site, vagrant, virtualbox

VirtualBox, Vagrant, Ruby, and Git have all gone through upgrades (major and minor) since I wrote the chapter on installing them in Multi-Site Drupal. While this hasn't made much of a difference for Mac and Linux/UNIX, Windows 7 support is now much better.

Here is a guide for installing the Multi-Site vagrant image for Drupal 7 on Windows 7. (If you're interested in running Drupal Vagrant, these instructions will work for that project as well.)

05 May

QueryPath in Practice: Migrating ICANN.org to Drupal

in drupal, html, import, migrate, php, programming, querypath

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.

21 Mar

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

in drupal, philosophy, php, programming, symfony

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.

28 Feb

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

in drupal, php, programming

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.

01 Feb

Documenting PHP with Doxygen: The Pros and Cons

in doxygen, drupal, php, programming

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.

10 Jan

Git drupal:// URLs for projects and sandboxes

in drupal, git

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.

10 Jan

Syntax Checking for Drupal in VIM

in drupal, php, phpcs, programming, vi, vim

SyntasticSyntasticVim (VI Improved) is a powerful text editor that comes standard on most versions of Linux, OS X, BSD, and other UNIXes. With thousands of add-ons, console and GUI versions, and a fully scriptable environment, you can transform a humble text editor into a powerful development tool. In fact, there are several Drupal add-ons for vim.

In this article, I explain how to turn on syntax checking for PHP, adding code style validation along with error checking. We do this with three tools: The Syntastic Vim plugin, the PHP CodeSniffer PEAR package, and the Drupal Code Sniffer project from Drupal.org.

06 Dec

Building a Custom Drupal Image for Vagrant

in drupal, php, ruby, vagrant, virtualbox

Not too long ago, I posted a blog entry about 5 reasons for using a virtual machine for Drupal development. At the suggestion of some commentors, I have started looking into using Vagrant to manage my VMs. There is an excellent Drupal Vagrant project that provides a great starting point. This article explains how to begin with that and modify it to suit your own needs.