PHP Joomla! 6 Joomla! 5 Module Intermediate

Create Modern services/provider.php for a Joomla 5 and 6 Module

Registers ModuleDispatcherFactory, HelperFactory and the Module service via the DI Container without a legacy mod_example.php entry file.

Updated on 24 November 2026 58 copies 191 views
modules/mod_example/services/provider.php
<?php

declare(strict_types=1);

\defined('_JEXEC') or die;

use Joomla\CMS\Extension\Service\Provider\HelperFactory;
use Joomla\CMS\Extension\Service\Provider\Module;
use Joomla\CMS\Extension\Service\Provider\ModuleDispatcherFactory;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;

return new class () implements ServiceProviderInterface {
    public function register(Container $container): void
    {
        $container->registerServiceProvider(new ModuleDispatcherFactory('\\Vendor\\Module\\Example'));
        $container->registerServiceProvider(new HelperFactory('\\Vendor\\Module\\Example\\Site\\Helper'));
        $container->registerServiceProvider(new Module());
    }
};
Pair with <folder module="mod_example">services</folder> and <namespace path="src"> in mod_example.xml.

Technical explanation and best practices

Modern Joomla 5 and 6 modules replace the procedural mod_example.php entry point with services/provider.php, wiring the module namespace, Dispatcher and HelperFactory directly into the DI container.

Direct Engineering

Have a Joomla project or technical challenge in mind?

From architectural diagnosis to production deployment, directly with the engineer.