Jump to main content Jump to doc navigation

modX::initialize

Initializes MODX engine into a Context.

This includes preparing the session, pre-loading some common classes and objects, and loading the current site and context settings. It also runs initialization classes that extension packages register to override session handling, error handling or other initialization.

Syntax

boolean initialize ([string $contextKey = 'web'], [array|null $options = null])
  • $contextKey (string) Indicates the context to initialize
  • $options (array|null) An array of options for the initialization

Returns true if the context was initialized successfully, or was already initialized; false otherwise:

if (!$modx->initialize('web')) {
    // initialization failed
}

Example

Initialize the 'sports' Context.

$modx->initialize('sports');

See Also

Support the team building MODX with a monthly donation.

The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.

Backers

  • modmore
  • STERC
  • Digital Penguin
  • Jens Wittmann – Gestaltung & Entwicklung
  • CrewMark
  • Fabian Christen
  • Sepia River Studios
  • Dannevang Digital
  • Alex
  • A. Moreno
  • Chris Fickling
  • Stéphane Jäggi
  • Murray Wood
  • Anton Tarasov
  • JT Skaggs
  • deJaya
  • Lefthandmedia
  • eydolan
  • Following Sea
  • Guido Gallenkamp
  • YJ
  • Raffy
  • Snow Creative
  • Nick Clark
  • Guest
  • Helen
  • krisznet
  • Yanni
  • Richard

Budget

$194 per month—let's make that $500!

Learn more