Jump to main content Jump to doc navigation

Loading the modX Object

Using the modX object (and all of its respective classes) is quite simple. All you need is this code:

require_once '/absolute/path/to/modx/config.core.php';
require_once MODX_CORE_PATH . 'vendor/autoload.php';
$modx = new \MODX\Revolution\modX();
$modx->initialize('web');

This will initialize the MODX object into the 'web' Context. Now, if you want to access it under a different context (and thereby changing its access permissions, policies, etc), you'll need to change 'web' to whatever Context you want to load.

From there, you can use any MODX methods, functions, or classes.

See Also