Drupal Planet

Performance Is Green

Posted: August 31, 2010 In / 2 Comments

49226298_da8ecc7ad6_m.jpgAre you writing and using environmentally friendly software? Have you ever thought of the impact on the environment for the software you've written? Working in front of a computer it can be easy to overlook the impact on the environment due to what were creating. It's not like drinking a beverage out of a styrofoam cup (they don't break down). But, there is an impact. As Internet usage grows in leaps and bounds we need to start taking a closer look at that impact and doing something about it.

Why Performance Is Green

Why did Facebook start using Hip-Hop? According to their blog,

With HipHop we've reduced the CPU usage on our Web servers on average by about fifty percent, depending on the page. Less CPU means fewer servers, which means less overhead.

When we have less servers we use less power, we need less space in buildings, less servers need to be built for our tasks and our overall footprint is smaller.

Think about it like this. We buy energy efficient appliances, we talk about turning lights off when we aren't using them, we look at energy efficient cars, and we think about being environmentally conscious. So, why not extend this to what powers our websites. Read more »

Accessing Libraries, Whether In Drupal or Elsewhere

Posted: June 10, 2010 In / 4 Comments

One of the assumptions regularly made is that libraries, like getid3 or Zend, live within the Drupal directory structure. The popular pattern is to put them in the libraries directory alongside the modules and themes directories. This is very limited both in workflow and accessibility to libraries. What if a developer wants to have a library in the PHP include path so multiple sites, not all of which are Drupal, can share it? What if someone wants to use Pear to manage that library? Let's take a look at a quick pattern for providing for a wide variety of possible locations for libraries. Read more »

The Time To Embrace PHP 5.3 Is Here

Posted: June 3, 2010 In / 11 Comments

PHP-logo.pngI am amazed at the number of Drupal modules that do not work under PHP 5.3. Until recently it had been acceptable to write code that didn't work in PHP 5.3. There was a small market share and the initial release of 5.3 had some bugs that made it worthwhile to rely on PHP 5.2. But, with the upcoming release of Drupal 7, which requires at a minimum PHP 5.2, and with PHP 5.3 starting to ship on some of the popular linux versions it's time to make sure Drupal sites run under 5.3 without any problems. Read more »

Debugging in Drupal 7

Posted: June 1, 2010 In / 6 Comments

I can't count the number of times I've seen print_r or var_export used while debugging code within Drupal. For those who use the devel module I see regular use of the dsm and dpm functions. In Drupal 7 this all changes for the better with the introduction of the debug function. Read more »

3 Tips For Using External Libraries With Drupal

Posted: May 17, 2010 In

There are more and more cases to use external libraries with Drupal. They may be jQuery plugins, CSS libraries, or PHP libraries already providing some form or function we want to use. But, so often we can't include then on drupal.org because of policy issues or there may be multiple modules wanting to use the same libraries which can cause collisions. Here are 3 tips for easily working with outside libraries. Read more »

The New Way To Generate Hashes In Drupal 7

Posted: May 13, 2010 In / 6 Comments

When we write Drupal modules generating hashes is a common task. They are usually generated as a md5 hash. Because of some new regulations for a large group of Drupal users it's time to migrate away from md5 to the SHA-2 family of hashes. Drupal 7 core has already migrated away from md5 and it's time for contrib modules to follow. Read more »

Architect Using Diagrams

Posted: April 29, 2010 In / 6 Comments

If you can't describe a system with simple diagrams the system is flawed. I've seen diagrams for cars, military vehicles, computer chips, and other very complex systems. Block and flow diagrams that simplify and explain in just the right amount of detail. Yet, when it comes to software applications, even complex ones, I am finding diagrams difficult to find. To make matters worse, when some systems that were architected in code do have diagrams put to them you find the picture is not so pretty.

theme-layer.pdf (page 2 of 4)

One of the best techniques I've learned for architecting a system is to start with diagrams. Read more »

Pluggable Entity Operations in Drupal 7

Posted: March 1, 2010 In / 2 Comments

In Drupal 7 core all the common objects, like nodes, users, comments, and terms, are called entities. Entities are a base level conceptual object designed to be used as a base for objects in core and contrib. But, there is a problem with the core entity pattern we can improve on in our contrib modules.

Entities have a controller used for their loading operations. The controller is a class that can be swapped out for alternative controllers when developers want to do something fancy, like have their own node caching setup. But, only the load operation is on the controller. The other CRUD (create, read, and delete) are hard coded in functions like node_load, node_save, and other object operations. The CRUD control for entities can't be completely swapped out. Let's take a look at a base pattern to use for completely swappable controllers. Read more »

SmartGit - The Best Git Gui So Far

Posted: February 24, 2010 In / 12 Comments

As Git becomes more popular and widely used a GUI becomes even more important. This was especially important when Drupal recently looked at what version control system it was going to switch to. (If you're interested in the Drupal (unofficial) decision checkout Angie Byrons post on groups.drupal.org)

When I surveyed the Git GUI landscape SmartGit stood above the rest for your standard user.

SmartGit Read more »

Downloading Dependencies With Drush Make

Posted: February 19, 2010 In

Quite a few Drupal modules rely on outside libraries to work. Some are JavaScript based requiring outside plugins and others are based on outside libraries. When users install these modules they, also, have to download and install the outside library. This is a pain that drush make and the Libraries API in modules can help with.

A typical setup will have a drush make file with a project and associated libraries defined within in them. The author who puts together the profile or top level make file will need to know the library and where it needs to go.

A little known feature about drush make files is that all projects can have make files and drush recursively builds each one out. So, if a module has a make file and the module is included in another make file the modules make file will be executed as well. Read more »