Jump to main content Jump to doc navigation


Name: Extension Packages Type: String(a JSON encoded array of key value pairs) Default: Yes

Use this setting to autoload packages that extend core classes, e.g. if you are extending modUser. The format should be a JSON array of key/value pairs where the key is the namespace (i.e. the package name) and the value is the path to its model.

This effect here is similar to other frameworks, e.g. CodeIgniter, which allows core classes to be overridden via use of a special classname prefix "MY_".

Use this only when you are extending core classes that are used during initialize()

Sample value


You can make use of the



Another Example

If your extension uses a different table prefix, you should list this in your JSON by using the tablePrefix key, e.g.


At some point in the recent version history, the addExtensionPackage and removeExtensionPackage convenience functions were added to facilitate adding and removing data to the extension_packages setting.


boolean addExtensionPackage ([string $pkg = ''], [string $modelpath = ''], [array $options = array()])

The $pkg argument really specifies a subfolder in the named model directory. In most packages, this name is the same as the package's namespace, but other packages may specify multiple sub-folders in their model. Note that the $options array can specify a "tablePrefix" key, e.g.

$modx->addExtensionPackage('mypkg', '/path/to/core/components/mypkg/model/', array('tablePrefix'=>'mypre_'));


When it's time to clean up, remove your node from the extension_packages array using this convenience function:

boolean removeExtensionPackage (string $pkg = '')