Loading MODX Externally
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.
$305 per month—let's make that $500!Learn more
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.