Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,075 of 9,075 pages
About the help in other languages
All help pages

Install scripts in a site package

How a site package carries PHP install scripts (settings/settings-file in package.xml, files in settings/), the eight functions the Create sites step calls and when, what each must return, the parameters they receive…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/site-packages/basics/install-scripts-in-a-site-package.md

On this page

Install scripts in a site package

This page is for developers who write or change the PHP part of a site package. It answers: how the scripts are declared, which functions the installer calls, in which order, with what, and what they must give back.

Contents

  1. Declaring the scripts
  2. The hook functions
  3. The order inside Create sites
  4. What the functions receive
  5. What the functions return
  6. The installer class pattern
  7. Rules and pitfalls
  8. Related pages

Declaring the scripts

The scripts are PHP files in the package's settings/ directory, each listed in package.xml:

<settings>
  <settings-file filename='ini-site.php'/>
  <settings-file filename='ini-admin.php'/>
  <settings-file filename='ini-common.php'/>
  <settings-file filename='sevenx-multi-site-installer.php'/>
  <settings-file filename='install-scripts.php'/>
  <settings-file filename='roles.php'/>
  <settings-file filename='preferences.php'/>
</settings>

The Create sites step includes every listed file that exists, with include_once, from <package path>/settings/<filename> (kernel/setup/steps/ezstep_create_sites.php). A file that is in settings/ but not listed is not included by the step; it can still be loaded by a listed file (the 7x installer loads post-install-fix.php with require_once).

Site packageListed scripts
sevenx_multisite, sevenx_multisite_cleanini-site.php, ini-admin.php, ini-common.php, sevenx-multi-site-installer.php, install-scripts.php, roles.php, preferences.php
cjw_multisitethe same, with cjw-multi-site-installer.php in place of the sevenx installer
plain_siteini-site.php, ini-admin.php, ini-common.php, roles.php, preferences.php

The hook functions

The scripts define plain PHP functions with fixed names. The step calls each one only when it exists (function_exists()):

FunctionCalledReturns
eZSitePreInstall( $siteType )after the scripts are included, before any required package is installednothing
eZSiteINISettings( $parameters )while the siteaccess settings are writtena list of INI changes for the public siteaccess
eZSiteAdminINISettings( $parameters )samea list of INI changes for the admin siteaccess
eZSiteCommonINISettings( $parameters )samea list of INI changes for settings/override
eZSiteRoles( $parameters )after the settingsa list of roles with policies and assignments
eZSitePreferences( $parameters )after the rolesa list of user preferences
eZSitePostInstall( $parameters )at the end of the stepnothing; may abort (below)
eZSiteFinalText( $parameters )lasttext for the wizard's Finished page

The names are kernel identifiers kept from the original product and are not renamed.

The order inside Create sites

  1. Fetch the site package (EZSW-041 when it cannot be fetched).
  2. Include the listed scripts, call eZSitePreInstall().
  3. Create the languages, then install the required packages in order (see Dependencies and install order).
  4. Build $parameters and call eZSiteINISettings(), eZSiteAdminINISettings(), eZSiteCommonINISettings(); write the results.
  5. Call eZSiteRoles() and create the roles; call eZSitePreferences() and set the preferences.
  6. Call eZSitePostInstall() with the content's language as the default language.
  7. Make the editor siteaccess, and the Admin UI siteaccess when exp_adminui is present.
  8. Call eZSiteFinalText().

What the functions receive

$parameters is built just before the INI hooks. Its keys include:

KeyContent
user_siteaccess, admin_siteaccessThe siteaccess names chosen in the wizard
siteaccess_urls, access_mapThe addresses and how siteaccesses are matched
package_objectThe site package (eZPackage)
node_remote_map, object_remote_map, class_remote_mapRemote IDs of the installed content, mapped to IDs
preview_design, design_listThe site's design and the design list (<design>, admin2, admin)
site_typeThe site type data from the wizard
all_language_codes, primary_language, extra_language_codes, fallback_language_codes, language_mapThe languages
database_settingsThe database settings the siteaccesses got

What the functions return

The INI hooks return a list of entries, each for one INI file:

return array(
    array( 'name' => 'site.ini',
           'reset_arrays' => true,
           'settings' => array( 'SiteSettings' => array( 'SiteName' => 'My site' ) ) ),
);

The public and admin entries are saved as .append.php files in settings/siteaccess/<name>/, the common ones in settings/override/. An entry that is false is skipped.

eZSiteRoles() returns entries with name, optional policies (each module, function, optional limitation) and optional assignments (each user_id, optional limitation with identifier and value). eZSitePreferences() returns entries with user_id and preferences (each name and value); a failed one is reported as EZSW-070.

The installer class pattern

The 7x and CJW packages keep the logic in one class and let each hook file only create it:

// install-scripts.php of sevenx_multisite
function eZSitePreInstall( )
{
    $installer = new sevenxMultiSiteInstaller( array( 'var_dir' => 'var/site' ) );
    $installer->preInstall();
}

function eZSitePostInstall( &$parameters )
{
    $installer = new sevenxMultiSiteInstaller( $parameters );
    $installer->postInstall();
}

sevenxMultiSiteInstaller extends the kernel's eZSiteInstaller (kernel/classes/ezsiteinstaller.php). eZSiteInstaller::postInstall() runs the list of steps from postInstallSteps() one by one (executeSteps()). When a step aborts, eZSiteInstaller::abortedStep() keeps it, and Create sites stops with EZSW-080: "The post-install of site package '...' stopped at step N of M (...): the steps after it did not run". What the 7x installer does step by step is described in The multisite installer script; the CJW one in The installer scripts.

Rules and pitfalls

  • One site package per run. The hooks are global functions, included once; only the chosen site package's scripts are included.
  • Settings are not stored back. eZPackage reads <settings> but does not write it; keep the list in the source repository (see package.xml reference).
  • The language during the post-install is the language the bundled content is in, not the primary language chosen; the step switches back afterwards.
  • No secrets in scripts. The scripts are published in the archive on the package server.
  • Test with every front end. The wizard, the kickstarter and exp:install all run the same Create sites step, so one test run covers the code path; test with a dry run first (see How the kickstarter and the console use packages).

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x