Updating custom plugins for Mautic 5

A plan for bringing in-house Mautic plugins from Mautic 4 to Mautic 5, covering CI, PHP 8.1 and 8.2 support, autowired services, the new config path and commit discipline.

On this page

Why custom Mautic plugins need their own upgrade plan for Mautic 5

If your in-house plugin was built for Mautic 4 and must run on Mautic 5 before Mautic 4.4's paid Extended Long Term Support ends on 31 December 2026, the plugin work is a separate project from the core platform upgrade, and it should follow Mautic's own plugin upgrade guide for moving from Mautic 4.4 to 5.1. The plugin is code your team owns, so the platform upgrade will not make it compatible on its own. Mautic's guide recommends a short, ordered set of changes: add continuous integration first, support PHP 8.1 and 8.2, move from Mautic 4.4 to 5.1, and adopt autowiring of services, which can remove most of a plugin's services configuration.

Plan the two tracks so they meet at a tested checkpoint. Start by listing every custom plugin, its owner, the Mautic features and events it hooks into, and any third-party services it calls. Then confirm with your team which PHP version and extensions the target environment will run, since the Mautic 5 install must match them. The platform upgrade itself, including Composer as the install method, the new config/local.php location and npm, is covered on the Mautic 4 to 5 upgrade page, so this section only sets the plugin plan that sits alongside it.

Work in small, reviewable commits so a regression can be traced to one change. Keep each commit to a single step from the guide, run your test suite and a smoke test of each plugin route after every step, and record the Mautic and PHP versions used. Ask any partner or internal team to state in writing which steps are included, who fixes failing tests, and how a test environment matching production will be provided before the plugin is moved forward.

What changes in Mautic 5 that affects plugin code

This table lists the Mautic 5 changes that touch custom plugin code, the impact of each one and the action your team needs to take. Work through the rows in order, because continuous integration gives you a repeatable test run for every later change. The main takeaway is that much of the work is configuration and test coverage, though you should confirm the scope against your own plugin.

ChangeImpactAction needed
Adding continuous integrationRuns plugin tests on every commit, so each later change has a pass or fail resultSet up a CI pipeline before changing code, and record a baseline test run on Mautic 4.4
PHP 8.1 and 8.2 supportPlugin code must run on the PHP versions Mautic 5 supports, and older syntax or functions may breakTest on PHP 8.1 and 8.2 in CI, and confirm the full PHP list in the Mautic developer docs
Autowiring of servicesCan remove most of the services configuration in the plugin's service filesEnable autowiring, remove redundant service definitions one at a time, and rerun tests after each removal
New local.php pathPlugin configuration and any code reading the old config location may fail to loadUpdate references to the new config/local.php location, confirm the path in the developer docs, and check install scripts
npm from Mautic 5.0 onwardMautic's front-end tooling runs through npm, so plugins with asset builds depend on itConfirm npm is available on build hosts and CI images, and check the plugin's own asset build steps

How to update a plugin in step-by-step commits

This sequence moves an in-house Mautic 4 plugin to Mautic 5 one verifiable change at a time, so every failure has a known commit to return to. Each step ends with a check that must pass before the next change begins.

  1. Add continuous integration against the Mautic 4 code

    Your team adds a CI pipeline to the plugin repository while it still targets the current Mautic 4 codebase. The pipeline should run the plugin's existing tests and static checks on the PHP version your Mautic 4 instance already runs. The step is done when the pipeline runs on every commit and passes on the unchanged code. This baseline matters because any later failure can then be attributed to a specific change rather than to the pipeline itself. Commit this as a standalone change, tagged or recorded so you can return to it.

  2. Get the Mautic 4 baseline green

    Before changing any plugin code, your team fixes whatever already fails on Mautic 4, such as broken tests, missing fixtures or deprecated calls the current release still tolerates. Confirm the plugin installs and loads on a copy of your production Mautic 4 instance. The check is a clean pipeline run and a successful install on the copy. Record the commit hash of the green baseline as the rollback point for the rest of the sequence.

  3. Move the target to Mautic 5.1

    Change the plugin's Composer constraints and dependency declarations so the code targets Mautic 5.1, the release the upgrade guide names as the step from 4.4. Keep this commit limited to version constraints and any changes needed to load on Mautic 5.1. Run the existing test suite and install the plugin on a Mautic 5.1 test instance built from a copy of your data. The check is a passing suite and a plugin that loads without errors on the 5.1 test instance. If it fails, return to the baseline commit and investigate the failing component in isolation.

  4. Add PHP 8.1 and 8.2 to the test matrix

    Extend the CI matrix so every commit runs against PHP 8.1 and 8.2 as well as your current version. Fix failures in small commits, one error class per commit, such as typed property changes, removed functions or stricter null handling. Your developers own these fixes, and a reviewer should check each one against the Mautic 5.1 test instance. The step is complete when the matrix is green on both PHP versions. If a fix has wider effects than expected, revert that single commit instead of reverting the sequence.

  5. Adopt autowiring and remove services configuration in small commits

    Enable autowiring and autoconfiguration for the plugin's services file, then remove explicit service definitions one group at a time. The upgrade guide notes that autowiring can remove most of a plugin's services configuration. Commit each removed group separately, such as event subscribers, then forms, then console commands, and run the full suite after each commit. The check for each commit is that the container still resolves every service the plugin uses and that the functional tests pass on the Mautic 5.1 instance. If a removal breaks a service, revert that commit alone and keep the explicit definition for that group.

  6. Move configuration to the new local.php path

    Relocate the plugin's configuration override from the Mautic 4 location to the Mautic 5 config/local.php path, with the keys updated to match. Keep this change in its own commit so it is easy to review and reverse. Install the plugin on a clean Mautic 5 instance and on your upgraded copy, then confirm that settings load from the new file and that no configuration is read from the old location. The check is that a fresh install reaches a working plugin state using only the new file. Tag the result as the release candidate for the next stage of testing.

What to inventory and set up before changing plugin code

Plugin work on Mautic 5 goes faster and fails less when the starting point is recorded before any code changes. The four items below give you a known-good baseline, a map of what the plugin touches, a test install that behaves like production, and a list of the integrations that need checks against live-like systems.

Current Git branch and tagged baseline

Start from a clean branch and tag the plugin as it runs today on Mautic 4.4, so every later change can be compared against a known state. Record the Mautic version, PHP version and the plugin's composer constraints in the tag message. Confirm that the working tree has no uncommitted changes from hotfixes applied directly on the server, because those changes are the most common cause of surprises during an upgrade. Keep the baseline tag until the plugin has passed testing on Mautic 5.

Plugin upgrade guide

Inventory of services, listeners and forms

List every service definition, event subscriber, form type, custom field, and route the plugin registers in its configuration. Note which of these are called by Mautic core, by cron jobs, or by other plugins, since those are the points where Mautic 5 changes will surface. Autowiring can remove much of the services configuration, so mark which entries are plain wiring and which carry custom arguments or factories that need a decision. Ask the developer who wrote each listener what business rule it enforces.

Test Mautic 5 install with background jobs

Build a copy of the production instance on Mautic 5, using a restored database snapshot and a separate domain that cannot send real email. Configure the cron jobs for segment updates, campaign updates and campaign triggers, staggered as the docs advise, and run a messenger consumer so queued emails and background work execute. Without these processes, plugin code that looks correct will appear to pass while the scheduled paths are never exercised.

CRM and email integrations to test live-like

List each integration the plugin or the wider instance uses, such as the HubSpot plugin that pushes contacts based on contact actions or point triggers, or a Salesforce connection. For each one, decide who owns a sandbox or test account and what data may flow into it. Confirm that field mappings, authentication tokens and webhook endpoints work against the test environment before the plugin changes go live. Ask the integration owner which sync errors they monitor today so you can reproduce them.

HubSpot plugin docs

How autowiring and the new config path change plugin structure

Autowiring is the change most likely to shrink a Mautic 4 plugin. Mautic's upgrade guide for Mautic 5 notes that adopting autowiring of services can remove most of a plugin's services configuration, because Symfony can resolve constructor dependencies by type instead of by hand-written argument lists. In practice, the Config/config.php file and any services definition file that listed every controller, model, helper and event subscriber can often be reduced to a short set of defaults and resource paths. Before you delete anything, record which services carry tags, aliases, factory calls or explicit arguments, because those still need to be declared. Plan a test run that compares the service container before and after the change, and confirm the exact syntax against the developer documentation for the target release rather than copying an older example.

What still has to be declared explicitly is the part teams most often get wrong. Autowiring does not know which interface a service should implement for a Mautic extension point, so event subscribers, form types, menu or route providers and any service that takes a scalar value such as an API key or a configurable setting usually need an explicit tag, alias or argument. Services that wrap third-party SDKs, or that must be shared or non-shared, also keep their declarations. Ask your developer team to list each explicit declaration in the plugin's change log so a reviewer can see what autowiring replaced and what it did not.

The move to config/local.php changes where site-specific values live. In Mautic 4 installs, settings were typically edited in app/config/local.php. The Mautic 5 layout places local configuration under config/local.php, and the upgrade guide is the source to confirm the file path, the array keys and any plugin-specific parameters for your target release. Keep plugin credentials and environment values out of versioned plugin code, and check that the file is not overwritten during a Composer update. Treat the path change as a checklist item in the test copy, with a clean install and a restored upgrade both verified before production.

Testing a plugin on Mautic 5 across environments

Local work usually starts from the Mautic GitHub repository, which gives developers the source tree and lets them run the plugin against a code base they can change and debug. This is the stage where the plugin's continuous integration should be in place before anyone trusts a green result, and where the target PHP versions are first exercised.

  • Continuous integration results: Confirm that the pipeline runs the plugin's unit and functional tests on PHP 8.1 and 8.2, and that failures are fixed rather than skipped.
  • Autowired services: Check that the service container loads the plugin without the old explicit services configuration, and that no service resolves to a missing class.
  • Config path: Confirm that the plugin reads settings through the local configuration location used by Mautic 5, not the Mautic 4 layout.
  • Commit hygiene: Keep each migration step in its own commit so a failing change can be reverted on its own.
  • Cron and queue commands: Run the segment, campaign and broadcast commands against a local database with test contacts, and confirm the plugin's listeners fire.

Nothing at this stage proves the plugin works on a real server with a real mail transport or CRM account. Record which checks passed locally so staging can focus on what local runs cannot reproduce.

What makes plugin upgrades take longer

How does the number of services and event subscribers affect a Mautic plugin upgrade?

The more services and event subscribers a plugin registers, the more wiring you must check, and the longer the upgrade takes. Each service definition in the plugin's configuration file must be reviewed against Mautic 5's container, and each subscriber must still receive the events it expects. Mautic's developer guide notes that autowiring of services can remove most of a plugin's services configuration, so a plugin with a large, hand-maintained service map usually has more to reduce and verify. Plugins with few services and simple subscribers move faster. Ask your team to count services, subscribers and custom event listeners before estimating, because that count tells you how much manual wiring must be re-tested.

Why do deprecated APIs in older plugins slow down an upgrade?

Deprecated APIs slow an upgrade because each call to a removed or changed method must be found, replaced and tested, and some replacements change behavior rather than just name. A plugin that calls core classes directly, extends internal base classes or relies on templates and hooks that changed between Mautic 4 and Mautic 5 needs a line-by-line review. Search the codebase for every core class it extends and every deprecation the Mautic 5 release notes list. The effort rises with the number of distinct deprecated calls, not the number of files, so a few widely used helpers can touch many features at once.

Does depending on a HubSpot or Salesforce plugin make a Mautic upgrade harder?

Yes, when your plugin depends on a third-party CRM or email plugin, the upgrade also depends on that plugin's release for the new Mautic line. Your code may compile cleanly while the integration fails at runtime because the vendor plugin has not yet been updated, or because it changed its contact-sync events. Mautic's HubSpot plugin pushes contacts based on contact actions or point triggers, and the Salesforce integration has its own configuration, so both can affect how your plugin receives data. Confirm the version of every dependent plugin for the target release, and plan integration tests against each one. Upgrades stall when a vendor release date is unknown.

How do missing automated tests increase the time needed to upgrade a plugin?

Missing automated tests force your team to verify every behavior by hand, which adds time and makes regressions easy to miss. Without a test suite, you cannot tell whether a change to a service or event subscriber broke an unrelated feature until someone runs that feature in a staging environment. Adding continuous integration before changing code is the sequence Mautic's upgrade guide recommends, so the first step is often writing tests for current behavior on Mautic 4.4 and running them against the existing code. Plugins with good coverage can be upgraded in small commits that each pass the suite, while untested plugins need larger manual regression passes.

Which PHP version gaps add the most work to a Mautic plugin upgrade?

The largest gaps add work because your code, its dependencies and its test tooling must all move together. Mautic's plugin guide for Mautic 5 covers PHP 8.1 and 8.2 support, so a plugin still written for an older PHP runtime needs syntax, type and library changes before it runs on the target versions. Check your current runtime, the PHP version of your production server and the PHP requirements of each Composer dependency. The further your plugin is from the PHP version Mautic requires, the more compatibility fixes and retesting you will need. Confirm the exact PHP floor for your target Mautic release on the requirements page before scoping.

How does queue and cron-driven logic make plugin upgrades harder to verify?

Queue and cron-driven logic is harder to verify because it runs outside a normal web request, so errors may appear only in logs hours later. Mautic depends on cron jobs for segment updates, campaign updates and campaign triggers, and emails sent through queues depend on a messenger consumer. A plugin that adds custom campaign actions, scheduled tasks or queued messages must be tested under those commands, with staggered timing and real queue processing. Plan a test environment that runs the same workers and cron schedule as production, and check the failure paths, not only the success path.

Can an in-house team upgrade its own Mautic plugins without outside help?

An in-house team can upgrade its own plugins if it has PHP and Symfony skills, a test environment that matches production, and time to work through each driver above. The team should list services, deprecated calls, vendor dependencies, test coverage, PHP gaps and cron or queue paths before committing to a schedule. Many teams find the hardest part is the missing tests and the untested background jobs, not the code changes themselves. An outside partner can take on that scoping and testing under a written scope, and DeployOpen plans and delivers this kind of work in your own infrastructure. Ask any provider for the written scope, deliverables and retest plan before agreeing on cost.

Each test gate stops the plugin upgrade and sends it to rollback

The sequence starts at a baseline on the Mautic 4.4 codebase, where continuous integration runs before any code changes. Each later phase is a separate, reviewable step: the PHP matrix, the move to a Mautic 5.1 target, the autowiring commits and the local.php move. Staging then runs the plugin with cron jobs and the queue consumer enabled, because production depends on both. Every test gate has a failure edge to the rollback branch, which returns the plugin to the last passing commit. Confirm each gate passes before starting the next phase.

Phased plugin upgrade path with a rollback branch fed by each test gate.

How to test and roll back a plugin release

Treat the plugin release as a set of test gates that must all pass before production changes. The first gate is continuous integration, which the upgrade guide recommends adding before the port starts, so every commit runs the plugin's unit tests and static checks against PHP 8.1 and 8.2. The second gate is a staging copy of the production Mautic 5 instance, built from a recent database dump and the same config/local.php, with the plugin installed from the release tag. Only a copy of real data shows whether field mappings, custom objects and segment filters still behave after the autowiring change. Ask your team to confirm that the staging database is a copy of production and that it is scrubbed of personal data if your data handling rules require it.

The third gate is the scheduled work. Mautic relies on cron jobs for segment updates, campaign updates and campaign triggers, plus a broadcasts command for segment emails and a messenger consumer when emails are queued. Run each of these by hand against staging with the plugin enabled, and confirm that the plugin's event listeners fire during campaign execution and not only in the web request. The fourth gate is the CRM sync check. If the plugin pushes or pulls contacts, run a small set of test contacts through the full path, then compare the records in the CRM sandbox with what Mautic logged. Record the results so a later rollback can be checked against the same cases.

A rollback should be a checkout of the last known good tag, not a manual file restore. Keep each step of the port as its own tagged commit, so the Mautic 4 branch and the last Mautic 5 release stay buildable side by side while you keep the Mautic 4 path available for the instance still running on it. Before any rollback, confirm with the plugin's authors what data the code writes: custom fields, contact or company records, campaign event logs, queued messages and any values stored in the CRM. Schema changes and new data are not always reversed by a code rollback, so decide in advance whether those records are kept, migrated back or removed, and test that decision on the staging copy first.

How DeployOpen scopes and delivers Mautic plugin upgrades

DeployOpen approaches Mautic plugin upgrades as a scoped engineering task inside your own infrastructure. We inventory each in-house plugin against the Mautic 5 upgrade guidance, then build, test and document the changes in steps your team can review and keep.

How we scope

  • We inventory every in-house plugin, its services configuration, hooks and test coverage before quoting.
  • The written scope names the Mautic 4.4 and 5.1 target versions, PHP 8.1 and 8.2 support and continuous integration setup.
  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
  • Ongoing support and continuous testing are available as a retainer after the upgrade is delivered.

How we build

  • We add continuous integration to the plugin repository first so each later change is tested automatically.
  • We move services to autowiring where it removes configuration, and document any service that must stay explicit.
  • We update Composer and PHP compatibility, then move configuration references to the new local.php path.
  • Each upgrade step is committed separately, so every change can be reviewed, reverted and traced.

How we hand over

  • You receive a written inventory of changes, test results and known gaps for each plugin.
  • Runbooks cover installing, testing and rolling back the plugin on a staging copy of your Mautic instance.
  • Your engineers get a walkthrough of the commit history, CI pipeline and remaining deprecations to address.

How we support

  • We can retest plugins after each Mautic patch, minor or major release to confirm they still load and run.
  • Support covers fixes for compatibility issues found in your environment, agreed in the retainer scope.
  • We confirm with you which Mautic release line and support dates apply before planning the next upgrade window.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.