Plugin Development Controller "The controller for URI "/s/myplugin" is not callable

Hello Mautic Community,

I just started learning how to make Mautic Plugin. I have not come far yet, but I am not giving up.

I created the following config file, which successfully adds a button to my Mautic (5.0.2) Menu on the left side

<?php

return [
    'name' => 'MyPluginBundle',
    'description' => 'Do Something with Mautic',
    'author' => 'McDiver', // Change this to  plugin author
    'version' => '0.0.1', // Change this version to your appropriate version'services'    => [
    'services' => [
        'helpers' => [
            'plugin.myplugin.model.myplugin' => [
                'class' => \MauticPlugin\MyPluginBundle\Model\MyPluginModel::class,
                'arguments' => []
            ]
        ]
    ],
    'menu' => [
        'main' => [
            'items' => [
                'plugin.myplugin.menu.index' => [
                    'iconClass' => 'fa-line-chart',
                    'children' => [
                        'plugin.myplugin.menu.upload' => [
                            'route' => 'myplugin_default',
                        ],
                    ],
                'priority' => -999,
                ],
            ],
        ],
    ],

    'routes' => [
        'main' => [
            'myplugin_default' => [
                'path' => '/myplugin',
                'controller' => 'MyPluginBundle:MyPlugin:default',
            ],
        ],
    ],
];

Next I want to call MyController if I press the submenu in the left bar (plugin.myplugin.menu.upload) Unfortunately, this is where I struggle. Mautic logs that the Controller is not callable. Do I get it right, that Mautic cannot find the controller itself, which I defined in routes path? Do I have to pass the path somewhere special?

The controller is in the Controller subdirectory and looks like this

<?php
/*
 * @copyright   2014 Mautic Contributors. All rights reserved
 * @author      Mautic
 *
 * @link        http://mautic.org
 *
 * @license     GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

namespace MauticPlugin\MyPluginBundle\Controller;

use Mautic\CoreBundle\Controller\FormController;

class MyPluginController extends FormController
{

    public function defaultAction()
    {
        $arn = "HelloWorld";
		// Here will follow some code...
    }
}

The target is that if I press the new menu in the left bar, I can see a mask for inserting some data, which shall later be pushed to some contacts. This is just an idea for learning.
I read all HelloWorld examples, took a look in other Bundles and asked ChatGpt, but unforutnately unsuccessfull.

Please let me know, if you need further information
I am happy to read from you! :slight_smile:

Check how the things are done in core, specifically the following two files:

Thank you for the answer. I had to put the enitre path to the config

'routes' => [
        'main' => [
            'myplugin_upload_index' => [
                'path' => '/myplugin/{page}',
                'controller' => '\MauticPlugin\MyPlugin\Controller\MyPluginController::indexAction',
            ],
        ],
    ],

Now I get the error message, that some namespace is wrong. But I will figure this out tomorrow

There are no registered paths for namespace "MyPluginBundle"." at [...]/vendor/twig/twig/src/Loader/FilesystemLoader.php 

This refers to the response of indexAction in the controller, where I currently return this

return $this->delegateView(
            [
                'viewParameters' => [
                    'para_test'      => 'test124',
                ],
                'contentTemplate' => '@MyPluginBundle/Integration/myfirst.html.twig',
                'passthroughVars' => [
                    'activeLink'    => '#myplugin_upload_index',
                    'mauticContent' => 'myplugin',
                    'route'         => $this->generateUrl('myplugin_upload_index'),
                ],
            ]
        );

A small step today, but better than nothing…