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:
The Profilename.install file will look like this:
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:
- 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:
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.
Allows choosing the language to use in the installer.
Loads the selected profile into memory.
Checks whether the current server meets the correct requirements for installing Drupal.
The form used to configure and rewrite settings.php.
Installs the system module so that the system can be bootstrapped, and installs the user module so that sessions can be recorded during bootstrap.
Does a full bootstrap of Drupal, loading all core functions and resources.
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).
Import available languages into the system.
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?