Drupal Installation Profiles - Part 3 - Roll your own

Trying to hatch your own Drupal Distribution? Or (more likely, like me) are you going through an iterative prototyping exercise? Time to create your own Drupal Installation Profile

This article How to Write a Drupal 7 Installation Profile provides some background information. Drupal 7 core provides 2 generic examples that you can examine:

  • Minimal
  • Standard

One caveat is that Installation Profiles are treated differently than modules. They are very similar to modules, but profiles can only exist under the core profile folder. This restriction may cause some Drupal religion conflicts. Core is sacred. Never hack core! But profiles are part of core... If you want to leverage profiles in order to easily rollout your own custom version of Drupal, you need to directly change / manage core as part of your application. You need to understand if this approach will work in your world. I have witnessed situations where Drupal core was controlled by the infrastructure team and the application developers were prevented from having any access to it. Custom Installation Profiles would not work in that world.

Not able to hack core? A simple alternative is to install the Minimal profile and then enable a special "configuration" module to perform the rest of the system setup and configuration. Makes the install a 2 step process, but avoids altering core. The minimal profile gives you a working base Drupal system. Your custom configuration module then enables (and configures) all of the optional core and required contributed modules that you need. The benefit of this scheme is that the configuration module can then later be used to contain update hooks when you are upgrading existing deployments. The update hooks can be used to enable and configure new contributed modules as the system is being extended.

Another caveat regarding Installation Profiles is that some portions of an Installation Profile execute before a full Drupal environment has been established. This means some Drupal hooks are not yet valid. You can place the hooks in your profile, but they are not active. In one set of experiments my attempts at using hook_form_alter to modify the installation database form did not work. I did not investigate to determine the exact cause.

The least effort design I finally settled on was to utilize a hybrid approach: a custom Installation Profile combined with a Configuration Module. I cloned the Standard profile, removed a bunch of undesirable dependencies from the .info file, altered some of the configuration code (new accounts now need Admin approval), removed some extra stuff (default content types)  and injected a dependency for my configuration module.  My configuration module then contained application specific code such as creation of custom content types.

This architecture allowed me to incrementally enhance my Installation Profile as I evolved my base system.