Got a new web project? Request a quote

Drupal Planet

Articles related to drupal

Speeding up your Drupal website with cloudflare

Cloudflare claims that can boost the speed of a website. But how much benefit can a site get? I am using Cloudflare for some drupal sites, but I never had a clear picture of how much the speed improvement really is. In this post I will present some data that I collected. The site I tested is a drupal site, but similar results can be expected for any other CMS like wordpress or joomla.

Running Drupal in Docker

In the simplest sentence, Docker allows to package software in an image that can run anywhere. Like virtual machines, Docker guarantees that the software that comes with the image will always run the same, regardless of the underlying environment.

Now, lets run Drupal in Docker! 


Do you have a backup strategy? 3 tools to save your day

For drupal we have a number of different methods to backup the database. Having a backup strategy is one of the easiest things to do but is often overlooked. Perform regular backups to keep your sanity when disaster hits. Implement a backup strategy for daily weekly and monthly backups and look cool to the client. I am going to discuss about 3 different tools to backup your database. Read on so you have no excuse.

What is the features module?

Some time ago, a client asked me about the features module. He wanted to know what the features module is about and how it can help him with his project. Their set up was a pretty complex e-commerce application involving multiple content types and integration with 3rd party services. Yet, they were not using features and would manually replicate any changes from the developer's machine to the server. He was concerned about maintaining the site and how he could add some new functionality without breaking the existing configuration. My recommendation was that they start using features. He had not idea what it was so I wrote him an email explaining. Read on my full reply.

Use drush to add a component to a feature like a drupal pro

Features is one of those modules we can not do without. One annoying issue with features is that it is slow. The bigger the drupal site, the slower the features UI pages load. And waiting for the page to load is one of the most disturbing things during drupal development.

Adding a new component to a feature is a multistep process: Go the features page, add the component to the feature, download the feature, remove the old feature and extract the new one. And repeat many times during the day.

Fortunately, we can speed this process quite a bit. Drush to the rescue again! This post is going to explain how to use drush to add new components to a feature.

How to use the Feeds api

Feeds ( is a very popular module. From the project page, we get a nice description of the module:

Import or aggregate data as nodes, users, taxonomy terms or simple database records.

The basic idea is that you throw a csv file to it and it creates drupal content. As simple as that. The input format can be more than just a csv, check the project page for more details.

We can use the feeds api if we want more functionality than the standard.
I am going to describe 3 different uses of the the feeds api:

  1. Perform an operation after a feed source has been parsed, before it will be processed
  2. Perform pre-save operations
  3. Add additional target options to the mapping form

How to write drush commands and hooks

I clearly remember the moment of excitement and joy couple of years ago when I discovered drush. Interacting with drupal from the command line? Wow! This was definitely something new to me, never seen it before in any cms.
Digging more, I discovered the wp-cli for the wordpress, but it seems that this in no way as mature as drush.

I use drush on a daily basis. For simple tasks such as clearing the caches or updating a feature to more complex stuff like in a deployment process or as an interactive php shell.

As with drupal, drush can also be extended. It is just a matter of writing the proper hook in the proper file. It is really simple and everyone can write their own drush commands.

As an example, I am going to show you how you to trigger a node save.

Find and export variables with drush or features

Features is a must have tool for deploying drupal sites. Features can be used for storing the website configuration in files, instead of the database. It can for example allow you to store a view in a file. You can then commit this code to your repo as usual.
Must of the site's configuration is stored in variables. Features, when used with strongarm, can be used to also export those variables from your staging env to your production. You can always find the name of the variable, by inspecting the html code. I use another trick to easily locate the variable name:

You can use

drush vget

to get the value of variable. For example,

drush vget cache

will return 1 or 0, depending on the value of the caching parameter set in admin/config/development/performance. If you dont know exactly the name of the variable, you can for example do a

Copy a remote database or backup with drush

I use drush a lot during development. A common task is to restore the database or copy the database from the stg server to my local machine.
A lot of people use Backup and migrate to do this which works fine but is just too many steps for me. With drush, this can be as long as a single command:

drush sql-sync @site-dev @self --sanitize

This command will copy the db from the dev server to the local machine.
The --sanitize switch will sanitize the email addresses and the passwords of the users. This way, you will be sure that there will no email accidentally sent from the devel machine.
Be carefull, not to switch the order of @site-dev and @self or you will copy the local db to the dev server.
It is usually good to do a:

drush sql-drop

before running the sql-sync command. This will drop the local db and it will likely save you some time troubleshooting.