WARNING: Matomo DDEV environment can be helpful when developing for Matomo, to be able to create or test new plugins locally, to run unit, integration, system or UI tests, but it is highly discouraged to use DDEV environments to run or host publicly accessible production installations of Matomo.
Before you begin, make sure you have DDEV installed. If you don't have it yet, follow the installation instructions in the official DDEV documentation.
If you don't have a Docker provider already available, you will need to start by choosing one. We recommend installing Rancher Desktop, as it is free and open source.
By default, Rancher Desktop will use ports 80 and 443 for Traefik router for Kubernetes. To make these ports available to DDEV, we recommend disabling Traefik by unchecking the checkbox: Preferences > Kubernetes > Enable Traefik.
Once DDEV is installed, navigate to your project directory and run:
ddev start
This command will start the DDEV environment for local development. By default, your local environment will be accessible at https://matomo.ddev.site.
You can also open this URL directly in your browser by running:
ddev launch
This will automatically open the default browser and take you to the Matomo setup page.
Follow the on-screen instructions in the UI installer to complete the Matomo setup. This will configure the necessary database and settings for your local instance.
After Matomo is set up, you can initialize the development environment by running:
ddev matomo:init:dev
This command will set up the environment for development, installing the additional dependencies required.
We have also added a parameter to the ddev matomo:init:dev command to enable source maps for Vue components.
To enable them, you can run:
ddev matomo:init:dev --with-sourcemaps
You can also disable sourcemaps at any time if you want to, just run the default command again:
ddev matomo:init:dev
NOTE: You should tick 'Disable cache' on your browser developer tools to see the changes.
To see help:
ddev help matomo:init:dev
After Matomo is set up, you can initialize the testing environment by running:
ddev matomo:init:tests
This command will set up the environment for running tests, ensuring everything is in place for the UI and other automated tests.
The command ddev matomo:console provides access to all Matomo console commands. Some useful commands include:
core:archive– Run local archivinggenerate:plugin- Generate a new plugin/theme including all needed filestests:run– Run unit, integration, and system teststests:run-ui– Run UI teststests:run-js– Run tracker JavaScript teststests:run-vue– Run Vue component unit testscache:clear- Remove all caches, including CSS and JavaScriptvue:build- Builds vue modules for one or more plugins
To mount local plugin repositories into Matomo without symlinks, use the host commands:
ddev matomo:plugins:mount
ddev matomo:plugins:mount ../plugin-FormAnalytics ../plugin-HeatmapSessionRecording
ddev matomo:plugins:mount ../ '^.*/plugin-(FormAnalytics|Funnels)$'
ddev matomo:plugins:unmount FormAnalytics
ddev matomo:plugins:unmount
ddev matomo:plugins:mount creates a local-only .ddev/docker-compose.local-plugins.yaml, adds bind mounts for discovered plugin-* directories, and restarts DDEV automatically. If you pass a plugin directory path directly, the command reads the plugin name from plugin.json when present and otherwise infers it from directory names like plugin-FormAnalytics.
When a plugin declares require.php in plugin.json, the mount command compares it with the PHP version currently used by DDEV. Simple constraints such as >=7.2.0 are enforced and incompatible plugins are skipped. More complex Composer-style expressions are only warned about and the plugin is mounted anyway.
ddev matomo:plugins:unmount removes one or more managed plugin mounts by plugin name. If all managed mounts are removed, the generated compose override is deleted automatically.
For more information about Matomo development, check out the official Matomo Developer Documentation.
You can create .ddev/config.local.yaml to adjust the environment configuration. This file will be automatically ignored by git.
For example, you can adjust php_version to 8.4. All configuration from .ddev/config.yaml can be overridden. Check DDEV documentation for more details.
From your host, run ddev restart for the changes to take effect.
To see some visits within your local Matomo instance, you don't need a website with the JavaScript tracking code installed. Instead, you can generate sample visits using the VisitorGenerator plugin.
Start by creating a site in the Matomo Dashboard. Then, run the following commands on your host machine:
ddev matomo:console development:enable
ddev matomo:console plugin:activate VisitorGenerator
ddev matomo:console visitorgenerator:generate-visits
Currently, the screenshots generated by UI tests do not match those generated in the CI environment. However, this does not affect the functionality of the tests themselves. The screenshots should still be good enough to verify that your changes or plugin are working correctly.