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
$194 per month—let's make that $500!
Learn moreLoading the modX Object¶
Load MODX with the config file, the autoloader and an instance from the registry:
require_once '/absolute/path/to/modx/config.core.php';
require_once MODX_CORE_PATH . 'vendor/autoload.php';
$modx = \MODX\Revolution\modX::getInstance();
$modx->initialize('web');
This initializes MODX into the 'web' Context. To work with a different Context — with its own access permissions and policies — replace 'web' with that Context's key.
Create the object with modX.getInstance rather than new \MODX\Revolution\modX(): only getInstance() registers it in the shared instance registry. An unregistered object is silently duplicated by the next getInstance() call.
See Also¶
- modX.getInstance
- Developer Introduction
- xPDO, the database layer of 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
$194 per month—let's make that $500!
Learn more










