2

I have an issue with the admin part of my website using CakePHP 3.2.

This part works really well on wamp in local but when I moved the site to the apache server, it stopped working. I have this error message :

Missing Controller Cake\Routing\Exception\MissingControllerException Error: DashboardController could not be found. Error: Create the class DashboardController below in file: src/Controller/Admin/DashboardController.php

And this error in the variables :

error : Unserializable object - Cake\Routing\Exception\MissingControllerException. Error: Controller class Dashboard could not be found in /data/vhosts/dev.droplet.ninja/htdev/vendor/cakephp/cakephp/src/Routing/Dispatcher.php, line 79

But the Controller exists at the right path with this content :

<?php
namespace App\Controller\Admin;

use App\Controller\AppController;

class DashboardController extends AppController
{

    public function index()
    {

    }
}

The prefix in my routes.php is :

// Admin namespace
Router::prefix('admin', function ($routes) {
    $routes->connect('/', ['controller' => 'Dashboard', 'action' => 'index', 'dashboard']);
    $routes->fallbacks('DashedRoute');
});

The routes works fine for the public part of the website but not for this. It seems that it can read the prefix and try to go to the file and even ask me to create the exact same file I already have. The only mistery is why it can't find him.

Also the Controller name is in :

src/Controller/Admin/DashboardController.php

I was looking for the differences between the two apaches settings without finding what can make cakePhp have this behavior.

Do you have any idea ?

Thank you

  • If the file is there, it's almost always a permissions problem. – Greg Schmidt Nov 11 '16 at 15:34
  • What do you mean by permissions ? To access the files on the server ? I just checked. The files have the following permissions rw-r--r-- (644). I am going to check with my authentication to see if it can be a problem there. Thanks for your help. – Mickael Lavieville Nov 14 '16 at 16:38
  • Ok, I checked, there is no problem here. Do you have other ideas ? – Mickael Lavieville Nov 17 '16 at 15:53
  • I don't have any other ideas, but then I haven't used admin routing in my projects yet. Start adding some debugging around line 79 of Dispatcher.php? – Greg Schmidt Nov 17 '16 at 23:46
  • Thank you, I had done that too. It seems that the problem is in a EventListener. Can It be an issue with a missing extension, or a version issue? I noticed that even if I set up wamp to use PHP 5.6.19 it uses PHP 7.0 for the CakePHP Apps. Which can maybe create a version conflict. – Mickael Lavieville Nov 21 '16 at 15:11
  • I tried to add a Plugin too instead of a prefix and I have the same issue. – Mickael Lavieville Nov 21 '16 at 15:12
  • Ok, I made it work with a Plugin. But it's still very strange that It doesn't work with the prefix. Thanks for your help. – Mickael Lavieville Nov 21 '16 at 17:24

1 Answers1

0

There's a multitude of reasons why it may not work. In my case, it was because of the old routes cache which I had to clear.

bin/cake cache clear _cake_routes_

You can get the list of cache prefixes by running bin/cake cache list_prefixes.

More info: /3.0/en/console-and-shells/cache.html

ᴍᴇʜᴏᴠ
  • 4,804
  • 4
  • 44
  • 57