Jump to main content Jump to doc navigation

Site owners use Upgrading from 2.x to 3.0. This page is for Extra authors who build or maintain transport packages. Compatible packages are listed on SiteDash. The Collection notes from theboxer (summary on modx.pro) are a worked example of an Extra that extends modResource.

Support scope

Goal Approach
MODX 3 only Namespaced classes, PSR-4 models, bootstrap.php. Drop require_once of old core paths.
One package for 2.x and 3.x Branch on version ($modx->version['version'] >= 3), class-name prefixes or dynamic parent classes. More work. Overview: Modernizing Extras cheat sheet.

Global aliases (modResource, modObjectCreateProcessor, and similar) still load by default in 3.0-3.2 through load_deprecated_global_class_aliases. Automatic loading is scheduled to stop in a future 3.x release — the source comment in core/include/deprecated.php says "likely 3.3 or 3.4" — so move to namespaced code before then. See Changed class names.

Checklist

  1. PHP: match the floor for the MODX line you support (requirements).
  2. Class names: in extends, type hints, and instanceof, replace short core names with MODX\Revolution\… / xPDO\…. Tables: Changed class names.
  3. Processors: extend the new processor namespaces. Remove flat-file processors. Drop require_once of core/model/modx/modprocessor.class.php and …/processors/resource/*.class.php (those paths are gone). Details: Processors.
  4. xPDO models: set schema package to a PHP namespace, version="3.0", regenerate metadata.mysql.php, call addPackage with a namespace prefix, register PSR-4. Guide: xPDO 3.
  5. bootstrap.php: optional file at the Extra core root (namespace path). Register autoload, addPackage, and DI services. See Namespaces and DI container.
  6. Menus / CMP: no modAction. Menu action is a controller name in the namespace (/manager/?namespace=myextra&a=home). See modAction and related.
  7. Manager JS: MODx.config.manager_language → MODx.config.cultureKey (Manager language).
  8. HTTP client: modRestClient is gone. Use the HTTP service.
  9. Build / install: test install and upgrade on MODX 3. Prefer current scaffolds (ModExtra3 for 3.x). Package markdown attributes are parsed in 3.0 (build script).

Example: Extra that extends modResource (Collections)

If a custom resource must show up in $modx->getDescendants(\MODX\Revolution\modResource::class), the schema extends value must be the namespaced core class.

Schema

Before:

<object class="CollectionContainer" extends="modResource">
    <!-- columns unchanged -->
</object>

After:

<object class="CollectionContainer" extends="MODX\Revolution\modResource">
    <!-- columns unchanged -->
</object>

Rebuild the model so metadata.mysql.php picks up the change.

PHP class and processors

Delete obsolete includes such as:

require_once MODX_CORE_PATH . 'model/modx/modprocessor.class.php';
require_once MODX_CORE_PATH . 'model/modx/processors/resource/create.class.php';
require_once MODX_CORE_PATH . 'model/modx/processors/resource/update.class.php';

Extend the namespaced types instead:

2.x 3.x
modResource MODX\Revolution\modResource
modResourceCreateProcessor MODX\Revolution\Processors\Resource\Create
modResourceUpdateProcessor MODX\Revolution\Processors\Resource\Update

Apply the same mapping to any custom {ClassKey}CreateProcessor / {ClassKey}UpdateProcessor. See Processors and Custom resource classes.

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
  • JT Skaggs
  • deJaya
  • Lefthandmedia
  • eydolan
  • Following Sea
  • Guido Gallenkamp
  • YJ
  • Raffy
  • Snow Creative
  • Nick Clark
  • Guest
  • Helen
  • krisznet
  • Yanni
  • Richard

Budget

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

Learn more