Blog Sections Open
Bootstrapping the MODX API from an External PHP File
External PHP scripts are a common integration point in legacy projects, but they only work reliably when the MODX API is bootstrapped correctly. Typical Bootstrap require_once($_SERVER['DOCUMENT_ROOT'] . '/manager/includ
External PHP scripts are a common integration point in legacy projects, but they only work reliably when the MODX API is bootstrapped correctly.
Typical Bootstrap
require_once($_SERVER['DOCUMENT_ROOT'] . '/manager/includes/protect.inc.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/manager/includes/config.inc.php');
define('MODX_API_MODE', true);
require_once($_SERVER['DOCUMENT_ROOT'] . '/manager/includes/document.parser.class.inc.php');
$modx = new DocumentParser;
$modx->getSettings();
Why Calls Still Fail
Developers often assume that once the parser is instantiated, every helper will behave like it does inside a normal page request. But some calls still require additional context or explicit parameters.
Practical Rule
If a chunk or parser call fails in an external script, first confirm the bootstrap sequence, then confirm what runtime context that helper expects. Standalone scripts rarely have the same document state as a normal page load.
When Too Many TVs Become a Content Modeling Problem
How to recognize the point where a project has outgrown ad-hoc TVs and needs a more deliberate content model.
Keeping YAMS and WebLoginPE Working Together
What to check when YAMS and WebLoginPE start producing blank pages or unstable output on multilingual Evolution CMS projects.