Jump to main content Jump to doc navigation

What is a Service?

A service is any object stored in the dependency injection container ($modx->services). In 2.x, and still in 3.x, many extras also load services with $modx->getService. That helper 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 list of the core-included MODX Services is as follows:

  1. modFileHandler
  2. modMail
  3. modRegistry

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

  • modmore
  • STERC
  • Digital Penguin
  • Jens Wittmann – Gestaltung & Entwicklung
  • CrewMark
  • Fabian Christen
  • Sepia River Studios
  • Dannevang Digital
  • Alex
  • A. Moreno
  • Chris Fickling
  • Stéphane Jäggi
  • Murray Wood
  • Anton Tarasov
  • deJaya
  • JT Skaggs
  • Lefthandmedia
  • eydolan
  • Following Sea
  • Guido Gallenkamp
  • YJ
  • Raffy
  • Snow Creative
  • Nick Clark
  • Guest
  • Helen
  • krisznet
  • Yanni
  • Richard

Budget

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

Learn more