Jump to content

Symfony Routing : Missing or invalid controller

Recommended Posts


I have been trying for several days to develop a module for order preparation. I am under version 1.7.5 and I code according to the new recommendations of PrestaShop for 1.7, so with Symfony. I tried to fix all my errors by myself, but I can't find the cause of this one.

At the installation, my module adds a tab in the order parameters. But here's the thing, I have the following result when I click on the tab :


However, I followed this documentation to the letter: https://devdocs.prestashop.com/1.7/modules/concepts/controllers/admin-controllers/

Here is my code for the tab, in the main file orderpreparation.php :

    private function installTab(): bool
        $tabId = (int) Tab::getIdFromClassName('AdminOrderPreparation');
        if (!$tabId) {
            $tabId = null;

        $tab = new Tab($tabId);
        $tab->active = 1;
        $tab->class_name = 'AdminOrderPreparation';
        //$tab->route_name = 'admin_order_preparation';
        $tab->name = array();
        foreach (Language::getLanguages() as $lang) {
            $tab->name[$lang['id_lang']] = $this->trans('Order Preparation', array(), 'Modules.Orderpreparation.Admin', $lang['locale']);
        $tab->id_parent = (int) Tab::getIdFromClassName('AdminParentOrders');
        $tab->module = $this->name;

        return (bool) $tab->save();

    private function uninstallTab()
        $tabId = (int) Tab::getIdFromClassName('AdminOrderPreparation');
        if (!$tabId) {
            return true;

        $tab = new Tab($tabId);

        return $tab->delete();

My controller code :


namespace Kaudaj\Module\OrderPreparation\Controller\Admin;

use Doctrine\Common\Cache\CacheProvider;
use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
use PrestaShopBundle\Security\Annotation\AdminSecurity;
use Kaudaj\Module\OrderPreparation\Model\PreparationLine;
use Kaudaj\Module\OrderPreparation\Repository\PreparationLineRepository;

class AdminOrderPreparationController extends FrameworkBundleAdminController
    private $cache;

    private $form_filename;

     * @var PreparationLinesRepository
    private $repository;
    public function __construct(CacheProvider $cache)
        $this->cache = $cache;
        $this->repository = new PreparationLineRepository();
        $this->form_filename = _PS_MODULE_DIR_ . $this->module->name . DIRECTORY_SEPARATOR . "orderpreparationform.html";

     * @AdminSecurity(
     *     "is_granted('read', request.get('_legacy_controller'))",
     *     message="You do not have permission to update this."
     * )
     * @return Response
    public function indexAction()
        return $this->render(
                "ajax_dl_link" => $this->context->link->getAdminLink($this->module->name)

My routes.yml file :

  path: /order-preparation
  methods: [GET]
    _controller: 'Kaudaj\Module\OrderPreparation\Controller\Admin\AdminOrderPreparationController::indexAction'

And finally, my composer.json file :

  "name": "kaudaj/order-preparation",
  "description": "Kaudaj - Order Preparation",
  "autoload": {
    "psr-4": {
      "Kaudaj\\Module\\OrderPreparation\\": "src/"
    "config": {
      "prepend-autoloader": false
    "type": "prestashop-module"

If you need more information about the context or some code I didn't publish, feel free to ask me.
Thank you in advance for your help!



Share this post

Link to post
Share on other sites

  • 2 weeks later...

So, I've made progress and here are my results:

I tested the demo module "democontrollertabs" with two versions of PrestaShop :

  • The, the version I currently use with my store.
    ==> Same result as with my module, i.e. the error "The controller is missing or invalid".
  • The beta 2, the last version released so far.
    ==> The demo module works correctly. On the other hand, my module always gives the same error. 🤯

I confess that I don't understand much anymore...
I changed a couple of things in my code, precisely to get as close as possible to the demo module.
By the way, it seems to me that I should add the vendor folder in the .gitignore ?

I'm not going to stop there and keep searching for the science 😂 but any help will be welcome!

Share this post

Link to post
Share on other sites

I was waiting to be sure, but it's good: I managed to get my module working!

In, my template was not good.
And for the previous versions, you have to add this for the main route, as specified in the doc :

    _legacy_controller: AdminOrderPreparation
    _legacy_link: AdminOrderPreparation

I got fooled because the demo module didn't have them, except that it's made for minimum so... my bad.
I thought I had already tested with these lines though but there was probably another error at the same time.

I didn't test for because I'm using the new Grid system which requires 1.7.6, so I'm going to upgrade my store to
But I think it should work too.

Good programming to all of you!

Edited by Vintelec (see edit history)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More