Jump to main content Jump to doc navigation


Include a class by fully qualified name. This is a handy way to perform an include_once operation to include a .class.php file. If the file is not found, false is returned and a warning is logged. This only includes the class: it does not instantiate an instance of it.


API Docs: https://api.modx.com/revolution/2.2/db_core_xpdo_xpdo.class.html#\xPDO::loadClass()

string|boolean loadClass (string $fqn, [ $path = ''], [ $ignorePkg = false], [ $transient = false])

The $fqn (fully qualified name) should in the format:


which will translate to:



  • The file name you are including must include .class.php as its extension.
  • The path to your model must end in a trailing slash!


Load a class from the path '/my/path/to/model/'.


Another example:

if (!$xpdo->loadClass('myBox','/my/path/to/model/',true,true)) {
    die('Could not load class myBox!');
$Box = new myBox();

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.


  • modmore
  • Jens Wittmann – Gestaltung & Entwicklung
  • Fabian Christen
  • Dannevang Digital
  • Digital Penguin
  • Sepia River Studios
  • Chris Fickling
  • deJaya
  • Following Sea
  • CrewMark
  • Anton Tarasov
  • eydolan
  • Raffy
  • Lefthandmedia
  • Murray Wood
  • Nick Clark
  • Helen
  • Snow Creative
  • YJ
  • krisznet
  • Richard
  • Yanni
  • JT Skaggs


$376 per month—let's make that $500!

Learn more