Matomo (formerly Piwik) can be used through several interfaces, the command line being one of them.
The CLI console enables users to run commands defined by plugins. The commands can be used to perform maintenance, to monitor the application, to ease development, and so on.
To use Matomo on the command line, all you need to do is run the console tool. The tool is a script located in Matomo's root directory and called
console. You can run it with the command:
php ./console help
The Matomo console is built using the Symfony Console component. If you are familiar with Symfony, you should immediately find your way in the Matomo console.
The console can be used to run Matomo commands like so:
The console comes with many commands, for example to generate empty plugins and plugin files with, run git commands, watch Matomo's log output, run tests, and deal with Matomo translations.
You can view the entire list of commands by running the following command:
To get more information about a single command (such as its arguments), run the following command:
./console help <command>
<command> should be replaced with the command you are interested in.
Plugins can extend the command line tool by creating their own commands. To do so you can use the CLI itself:
./console generate:command --pluginname=MyPlugin
This will create a folder named
Commands within your plugin along with a PHP file which represents the actual command. You can add an unlimited number of commands to a plugin.
To learn how to flesh out your command, you can read the Symfony Console documentation.