MODX Services
Last updated Oct 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
$185 per month—let's make that $500!
Learn moreWhat is a Service?¶
A service is any object stored in the dependency injection container ($modx->services). Many extras still load services with $modx->getService, a 2.x pattern that is deprecated in 3.x. Prefer has / add / get on $modx->services.
Once a service is in the container, you can also hang it on $modx yourself ($modx->error = $modx->services->get('error')). getService did that automatically.
$modx->services->add('twitter', function($c) use ($modx) {
return new MyPackage\Twitter($modx, ['api_key' => 3212423]);
});
$modx->services->get('twitter')->tweet('Success!');
What are the Default Included Services?¶
A few services are registered in the container during MODX initialization:
registry— modRegistry, instantiated eagerly at the end ofmodX::initialize();- the seven PSR HTTP services listed on the HTTP Services page (
ClientInterface,ServerRequestFactoryInterface,RequestFactoryInterface,StreamFactoryInterface,ResponseFactoryInterface,UploadedFileFactoryInterface,UriFactoryInterface); modManagerDateFormatter(registered under its class name), used by the manager;lexicon,errorandparserare also placed in the container as initialization proceeds.
Other core services are part of the distribution but are loaded on demand via $modx->getService rather than pre-registered:
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
$185 per month—let's make that $500!
Learn more










