modX.loadClass
Last updated not available | 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 moremodX::loadClass¶
Deprecated since 3.0 — reference MODX\Revolution\* classes directly and let the PSR-4 autoloader load them.
The name is resolved in this order:
- A namespaced name that already exists is returned unchanged.
- A plain or dotted name such as
modx.modChunkis mapped ontoMODX\Revolution\. The old name gets aclass_alias()when it is missing, a deprecation is recorded, and the PSR-4 name is returned. - When that guess fails, the method returns what
xPDO::loadClass()answers: the class name orfalse.
A non-empty $path skips step 2. $path, $ignorePkg and $transient apply only in step 3.
Syntax¶
bool|string loadClass (string $fqn, [string $path = ''], [bool $ignorePkg = false], [bool $transient = false])
-
$fqn(string) class name, plain, dotted or namespaced -
$path(string) directory searched byxPDO::loadClass(), by default'' -
$ignorePkg(bool) skip the package search insidexPDO::loadClass(), by defaultfalse -
$transient(bool) load without the metadata map insidexPDO::loadClass(), by defaultfalse
Example¶
$class = $modx->loadClass('modx.modChunk');
// 'MODX\Revolution\modChunk'
$missing = $modx->loadClass('modMissingClass');
// false, and xPDO logs "Could not load class"
See Also¶
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










