This project is not covered by Drupal’s security advisory policy.

This is an API project / libary that gives installation profiles (and select modules during install) the ability to implement hook_site_pre_install() and hook_site_post_install().

Is this the right module for me?

Consider the following questions to determine if this is the right approach for you:

  1. Are you building an installation profile?
  2. Have you ever needed to execute code right before all of the modules the profile depends on get installed?
  3. How about executing code after the entire profile has been installed?

If you answered YES to at least two of the questions above, then this code is for you!

You can technically accomplish what this code does for you simply by implementing your own install tasks via hook_install_tasks() or hook_install_tasks_alter(), but why do that when this code abstracts having to deal with that away from you?

Sample Use Cases

Here are some scenarios where you'd want to use this approach:

  • You need to configure certain site settings before installing a module that requires those settings (hook_site_pre_install()).
  • You need to modify user passwords, tweak menu paths, or adjust settings (such as the site name) that would otherwise be bashed if set in hook_install() in the installation profile (hook_site_post_install()).

How to Use

Do not install this project like a regular module! It serves no purpose after site install. See the README.

Either hook_site_pre_install(), hook_site_post_install(), or both can be implemented in the .install file of your profile.

In addition, hook_site_post_install() can also be implemented in the .install file of modules or features, as a handy way for features to perform one-time installation logic only when the site is being installed (as opposed to when being installed on an existing site for the first time).

By design, hook_site_pre_install() cannot be implemented by modules because it is invoked before the site knows what modules are going to be available.

Compatibility with Profiler

This library is already incorporated into Profiler as of #2418335: Provide hooks for site pre-install and post-install hooks. If you are using Profiler, you do not need this library.

Supporting organizations: 
Primary developers.

Project information

Releases