Loading Packages
Last updated Aug 15th, 2026 | 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
$213 per month—let's make that $500!
Learn moreWhat are xPDO Packages?¶
Packages are collections of maps and classes that represent tables in a database. It's the ORM layer, usually stored inside of a component's "model/" directory.
How are they used?¶
Packages are loaded in xPDO via the addPackage method or the addExtensionPackage methods. The addPackage method is appropriate for plugins and Snippets that need to load up classes and table data on demand. addExtensionPackage is a convenience method which ultimately relies on addPackage. When a package is added via addExtensionPackage, it is loaded with each MODX request; it is more appropriate for packages that alter core functionality.
The addPackage method takes the package name, the absolute path to the model directory, and an optional table prefix. If you omit the prefix, xPDO uses the connection default (xPDO::OPT_TABLE_PREFIX), which in MODX is the site table prefix. Do not pass a custom table prefix unless the package tables intentionally use a different prefix than MODX. A hard-coded third argument overrides the MODX prefix and breaks installs that changed table_prefix (see xPDO.addPackage).
Assume an xPDO model package (maps and classes) lives in:
/myapp/core/model/boxpackage/
Load it with the connection prefix:
$xpdo->addPackage('boxpackage', '/myapp/core/model/');
From then on, load package classes through xPDO’s retrieval methods.
Conclusion¶
Now that you've got your package loaded, you'll want to look into creating objects, or adding rows to your tables, with xPDO.
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
$213 per month—let's make that $500!
Learn more










