Hachther Blog > Open Source  > How to develop a Mautic plugin: MVC – Routes

How to develop a Mautic plugin: MVC – Routes

Welcome to the lesson II of the series Develop a Mautic plugin. If you have not read the previous article I highly recommended you to do it (you can find it here).

Mautic is based on Symfony which is a MVC PHP framework. So, develop a module in Mautic means that you will work follow the MVC paradigm but with Mautic rules. So in the article we will give a brief description of MVC then the first big step for module development: configuration of routes and menus.

MVC stand for Model View Controller which is a software architecture pattern. MVC define three components:

  • Model: responsible for the interaction with your data.
  • View: responsible for the presentation to the user.
  • Controller: responsible for bind data from the model and display the view.

And to give access to the user you need to define routes so ca have access to resources.

And to give access to the user you need to define routes.

In the next, we will configure routes (MVC paradigm) and menus (Mautic specification) to display routes to the user. And before we continue, we need to define one of the most important things: the key name of the module, which will be used in all our configurations.


All configurations are done Config/config.php: routes, menus, service, categories, … We will only focus on the configurations for basic MVC module and to do that, we only need to add route and menu configurations. As define the previous article, our module name is HelloWord and the key name is helloword. Let us configure the routes for different actions and the menu to give access to our module to a user.


Mautic have three types of routes:

  • main: users need to be authenticated to have access to those routes. (/s/ will be automatically appended)
  • public: those routes will be accessible for everyone authenticated or not
  • api: accessible only through API secure requests (/api/ will be automatically appended)

For a route you need to define some required parameters and some other optionals, depending on your needs.

  • path (required): is the path used in the browser (since Mautic is base on Symfony this path definition follows the same rules as Symfony).
  • controller (required): Is the action to call when this route is triggered. We will see how to define a controller in the next article.
  • method (optional): is the HTTP method (GET, POST, …) which need to be used to trigger this route.

There are other parameters which can be defined in the route, you can find a full documentation here.

Each of your routes must have a unique name, name which will be used to refer to this route in the other configurations or in your source code.

In this article, we will only focus on the main route.


Mautic have 4 types of menus:

  • main: Main menu on the left.
  • admin: Admin menu accessible through the cogwheel in upper right-hand side of Mautic.
  • profile: Profile menu accessible through clicking the username in upper right-hand side of Mautic.
  • extra: Displays to the right of the Mautic logo in the upper left hand. Only shows if there are menu items injected.

Same like routes, menu has some parameters that you can set.

  • route (optional): The name of the route to link to this menu.
  • parent (optional): Display this item under another parent menu item.

There are other parameters which can be defined in the menu, you can find a full documentation here.

In this article, we will only focus on the main menu.

Config file

This is what your file will look like.

	'description' => 'Hello Word module',
	'version' => '1.0',
	'author' => 'Hachther Co.',

	'routes' => [
		'main' => [
			'mautic_helloword_index' => [
				'path' => '/helloword/{page}',
				'controller' => 'MauticHelloWordBundle:HelloWord:index',
				'method' => 'GET'
			'mautic_helloword_action' => [
				'path' => '/helloword/{objectAction}/{objectId}',
				'controller' => 'MauticHelloWordBundle:HelloWord:execute',
	'menu' => [
		'main' => [
			'mautic.helloword' => [
				'route'    => 'mautic_helloword_index',
				'parent'   => 'mautic.core.channels',

As you can see, make a configuration file is just a matter of return a php array with a specific structure. We have routes ( with main routes within) and menu (with main menu within) and for each element you define a unique name and your configuration within.

This is the end of this article. Hope this was helpful and see you in the next article.

Previous article

  • Norman Carrie
    April 28, 2018 at 3:24 pm

    So how would you create an operation that you wanted to kick off with the console?

  • Esmeralda
    May 27, 2020 at 12:45 am

    Fantastic goods from you, man. I’ve understand your stuff previous to and you are just extremely excellent.
    I actually like what you have acquired here, really like what you are stating and the
    way in which you say it. You make it entertaining and you still
    care for to keep it sensible. I cant wait to read much more from you.
    This is really a tremendous web site.

  • Marcella
    May 30, 2020 at 11:07 pm

    Hey There. I found your weblog the use of msn. This is a really neatly
    written article. I’ll make sure to bookmark it
    and come back to learn extra of your helpful information. Thanks for the post.
    I will certainly return.

  • Kathryn
    May 31, 2020 at 6:20 am

    I was able to find good advice from your content.

  • Dewey
    June 1, 2020 at 8:12 am

    I’m curious to find out what blog system you are using? I’m having
    some small security problems with my latest website and I would like to find something more safe.
    Do you have any recommendations?

  • Kassandra
    June 1, 2020 at 4:21 pm

    We are a group of volunteers and starting a new scheme in our
    community. Your website offered us with valuable info to work
    on. You’ve done an impressive job and our entire community will be thankful to you.

  • Christen
    June 4, 2020 at 2:49 am

    Wow, fantastic weblog layout! How long have you ever been blogging for?
    you made blogging look easy. The total glance of your site
    is magnificent, as smartly as the content material!

  • ปั้มไลค์
    June 12, 2020 at 10:20 pm

    Like!! I blog frequently and I really thank you for your content. The article has truly peaked my interest.

  • Charli
    June 13, 2020 at 3:08 am

    Hi just wanted to give you a quick heads up and let
    you know a few of the pictures aren’t loading properly.

    I’m not sure why but I think its a linking issue. I’ve tried it in two different browsers and both show the
    same outcome.

  • Steffen
    June 29, 2020 at 6:22 am

    you’re in point of fact a excellent webmaster.

    The web site loading pace is amazing. It seems that you’re doing any
    distinctive trick. Furthermore, The contents are masterwork.

    you have done a magnificent process on this topic!

  • Larue
    January 21, 2021 at 2:52 am

    An impressive share! I have just forwarded this onto a colleague who had been conducting
    a little research on this. And he actually bought me lunch because I discovered it for him…
    lol. So let me reword this…. Thanks for the meal!! But yeah,
    thanks for spending the time to talk about this issue
    here on your internet site.

  • Crystle
    January 21, 2021 at 12:05 pm

    I think that is among the most significant information for me.

    And i am happy reading your article. However want to commentary on few common issues, The web site style is wonderful,
    the articles is really excellent : D. Excellent process, cheers

  • Rusty
    January 21, 2021 at 3:31 pm

    It’s actually a great and useful piece of info. I’m happy that you simply shared this helpful info with us.
    Please stay us informed like this. Thanks for sharing.

  • Johnie
    February 23, 2021 at 12:47 am

    Very soon this site will be famous amid all blog users, due to it’s fastidious posts

  • Jacques
    March 17, 2021 at 3:20 pm

    What’s Happening i’m unfamiliar with this, I found this We have found It
    positively useful and features aided me out loads. I’m hoping to provide a contribution &
    assist other users like its helped me. Great job.

    Here is my webpage – RenatoCPanek

  • Rick
    April 20, 2021 at 5:52 pm

    This is my first time go to see at here and i am genuinely pleassant
    to read everthing at alone place.

  • Bonny
    April 22, 2021 at 3:31 pm

    I visited many web pages however the audio feature for audio songs
    current at this web site is really fabulous.

Leave a reply