Loading MODX Externally
Last updated Sep 14th, 2022 | Page history | Improve this page | Report an issue
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
Budget
$301 per month—let's make that $500!
Learn moreLoading 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¶
- Developer Introduction
- xPDO, the db-layer for Revolution
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
Budget
$301 per month—let's make that $500!
Learn more