Main Content
person typing on laptop

How to Create a Drupal Installation Profile

An installation profile "turns on" functionality and pre-configures a Drupal Installation so that, instead of starting with a blank slate, you have a customized installation fit for your needs and close to being production-ready. It is important to note that installation profiles need to have profilename.info and profilename.profile files. They can also have a profilename.install file as well.

 

The Profilename.info file should look like this:

; $Id$
name = Profile Name
description = Description of what the profile does.
core = 7.x
dependencies[] = block
dependencies[] = color
dependencies[] = comment
dependencies[] = contextual
dependencies[] = dashboard
dependencies[] = help
dependencies[] = image
dependencies[] = list
dependencies[] = menu
dependencies[] = number
dependencies[] = options
dependencies[] = path
dependencies[] = taxonomy
dependencies[] = dblog
dependencies[] = search
dependencies[] = shortcut
dependencies[] = toolbar
dependencies[] = overlay
dependencies[] = field_ui
dependencies[] = file
dependencies[] = rdf
files[] = profilename.profile

 

The Profilename.install file will look like this:

<?php
/**
* Implement hook_install().
*
* Perform actions to set up the site for this profile.
*/

function profilename_install() {
  include_once
DRUPAL_ROOT . '/profiles/standard/standard.install';
 
standard_install();
}

?>

 

Addition of steps to the install:

New steps are added in hook_install_tasks() by returning an associative array. 

 

Additional tasks should look like this:

<?php
$task
['machine_name'] = array(
 
'display_name' => st('Human-readable task name'),
 
'display' => TRUE,
 
'type' => 'normal',
 
'run' => INSTALL_TASK_RUN_IF_REACHED,
 
'function' => 'function_to_execute',
);

?>
  • The Machine_name is the internal name of the task.
  • The Display_name is the human-readable name of the task.
  • Display determines whether or not you show this task in the list of installation tasks on the side of the installation screens.
  • Type is either normal (return HTML), batch (batch array), or form (form API structured array).
  • Run is either INSTALL_TASK_RUN_IF_REACHED, INSTALL_TASK_RUN_IF_NOT_COMPLETE, or INSTALL_TASK_SKIP.  
  • The function is the function that will be run when the task is executed.

 

Changing or removing steps from the install process

You can change or remove steps from the install process via Hook_unstall_alter(). Here is a list of the default tasks:

  • install_select_profile

A configuration page to select which profile to install. It doesn't make any sense to change this, because by the time your profile gets control, it will have already been chosen.

  • install_select_locale

Allows choosing the language to use in the installer.

  • install_load_profile

Loads the selected profile into memory.

  • install_verify_requirements

Checks whether the current server meets the correct requirements for installing Drupal.

  • install_settings_form

The form used to configure and rewrite settings.php.

  • install_system_module

Installs the system module so that the system can be bootstrapped, and installs the user module so that sessions can be recorded during bootstrap.

  • install_bootstrap_full

Does a full bootstrap of Drupal, loading all core functions and resources.

  • install_profile_modules

Installs and enables all modules on which the profile depends (as defined in the .info file), and then runs profilename_install() if it exists (as defined in the .install file).

  • install_import_locales

Import available languages into the system.

  • install_configure_form

A form to configure site information and settings.

 

Updating the installation profile

Similar to modules, installation profiles use hook_update_n() functions so that they can be updated to a newer version.  Use this update function to install the newer version of the install profile. 

 

Packaging an installation profile on Drupal.org

What now?  You have created and perfected your installation profile.  You have created the files and functions to install, update, and maintain them as well.  The next step is to package your profile for distribution.  Here is a nifty guide on how to package a profile on drupal.org

Want to learn more about Drupal?

Sign up for training.