An overview of D7 install profiles

3 comments

Yet another key component to the Drupal Platform is the install profile and it's another one that deserves a few posts to cover it adequately. The goal of this series of posts will be to build an install profile capable of creating a basic brochure-style website - more or less what WordPress's core functionality offers (ok, we'll be doing a bit less for this example ;-)).

Drupal 7 install profiles differ quite significantly from Drupal 6 install profiles so a lot of the material covered here won't necessarily apply if you're working on D6 only. There's already a lot of great documentation to help get you started. Drupal.org has an overview of install profiles that's worth taking a read through, for example. The Drupal documentation also covers all of the common hooks that you may want to use in your profile. But the best place, without question, is just reading through the Drupal core profile code (no, I'm not joking). Check out profiles/minimal, and profiles/standard folders that come with Drupal, particularly the .info, .profile, and the .install files.

To be upfront about things here, I've personally never built an install profile in Drupal 7 so this is a bit of a learning experience for me as well. I know that a lot of the limitations that existed in Drupal 6 have been solved so hopefully the process will be smoother. As always, if you notice anything I've done wrong or could do better please leave a comment as I want to promote best practices for building platforms.

There are a few differences between an installation profile that you'll run manually as you install Drupal (an option that would sit next to minimal or standard in the Drupal install process) versus an install profile to be used for automatically creating sites through Aegir. The primary difference is that an install profile to be used in Aegir should have no options that the user needs to fill out or answer. Defaults are important here. Any kind of setup that the user must do will need to be done after the site it created, not before, possibly with some sort of configuration wizard for this which I'll hopefully write more on later.

For this post I'm only going to run through a typical install profile as opposed to an Aegir-specific one which I'll write on later (and conveniently, can be much simpler than a standard profile).

Anatomy of an install profile:

The initial setup for the install profile is quite trivial. All you need to do is create the folder and the files, and then list out the modules you wish to be enabled on site creation. Basically a combination of creating a new site in a multisite setup and creating a module.

Start with this folder structure in your D7 site:

profiles/brochure
profiles/brochure/brochure.info
profiles/brochure/brochure.install
profiles/brochure/brochure.profile 
profiles/brochure/modules
profiles/brochure/modules/contrib
profiles/brochure/modules/custom
profiles/brochure/modules/features
profiles/brochure/themes

All the non-core modules used on your site will now go into the installation profiles' folder as opposed to sites/all. This isn't required, but will make your install profile more complete and is a good way to keep things organized.

.info

Unlike in D6 install profiles, you define the modules you want to install with your profile in the .info file as a dependency, just as you would with a standard drupal module. This makes install profiles much more consistent with how the rest of drupal packages work, and more importantly, makes our life easier.

.profile

The .profile file is equivalent to the .module file in a module or template.php in a theme. This is where you'll define any hooks required for your profile. Unlike Drupal 6, install profiles in Drupal 7 now have the privilege of running under a fully bootstrapped Drupal. This is a huge benefit, and makes the life of an install profile in D7 much more enjoyable than those poor D6 profiles.

.install

The tough part comes in the .install file. Take a look at the profiles/standard/standard.install file. It starts by defining and creating filter formats and then blocks. It also includes the creation of content types, fields, rdf mappings, roles, and menus.

The good news is that a huge percentage of this, the heavy lifting, can be removed by the use of features. For example, we don't need to create content types, fields, roles, menus, etc. by hand as they're all defined and created by the features we use on our site (see A simple feature for reference).

The bad news is that for more complex profiles you will need to get into the nitty gritty of the Drupal API. In some cases the install profile api (http://drupal.org/project/install_profile_api) can simplify things for you (at the time of writing there is not yet a D7 version), but for most things you should look at other install profiles for examples.

In my next post I'll demonstrate creating the skeleton of a basic profile based off of the Drupal minimal and standard profiles as well as a little pinch of our own special sauce.

Peanut Gallery

d7 profile helper module

david

D7 profiler_api type module at www.drupal.org/project/profiler

Also, there is now a simple GUI interface to create a profile:
http://drupal.org/node/1283448

.... totally annoyed by cool modules such as Ckeditor that only look in sites/all/modules for dependencies, as clearly they can live in other places besides sites/all/modules. I wish Library would catch on.
http://drupal.org/node/1210380

Doing stuff by hand is great. But leveraging a tool like Profiler + Drush Make can get you there really fast:
http://chicago2011.drupal.org/sessions/zero-distribution-using-features-profiler-and-drush-make

Currently building a site via install profile and all the tools i've outlined above. Nice writeup look forward to the followups.

Hello, New to drupal so

Tony Imtiaz

Hello,

New to drupal so please bear with me. Started off with a distribution profile / subtheme that is based on Zen. However I cannot see the contents of the subtheme on my webpage (tppc.webcltd.com) despite enabling and configuring the subtheme. Your help will be much appreciated.

Tony

This is a good introduction

This is a good introduction to installation profiles but I have one question (actually I've got a few, lol). How is the cascade defined? For example, I installed Commerce Kickstart and despite both Standard and Minimal installation profiles being there, it "knew" to load the Kickstart profile when I went to site.local - where is this defined?

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options