1
votes

I have a CakePHP 3 app and it has different plugins. The plugins appear to load and accessing them on a dev Windows machine, WAMP, it all works fine.

Once on the CentOS server, the plugin's prefix routing eg 'admin' stops working, getting a missing controller error: enter image description here

Log error:

2018-04-11 12:40:23 Error: [Cake\Routing\Exception\MissingControllerException] Controller class Contacts could not be found.
Exception Attributes: array (
  'class' => 'Contacts',
  'plugin' => 'Contacts',
  'prefix' => 'admin',
  '_ext' => NULL,
)
Request URL: /myapp/contacts/admin/contacts
Referer URL: https://***/myapp/anotherplugin/participants
Stack Trace:
#0 /srv/www/myapp/myapp-app/webroot/index.php(36): Cake\Routing\Dispatcher->dispatch(Object(Cake\Network\Request), Object(Cake\Network\Response))
#1 /srv/www/myapp/myapp-app/index.php(16): require('/srv/www/mya...')
#2 {main}

The controller does exists and contains:

namespace Contacts\Controller\Admin;

use Contacts\Controller\AppController;

use Cake\ORM\TableRegistry;
use Authentication\Utility\TimeUtility;
use Cake\I18n\Time;
use Cake\Core\Configure;

class ContactsController extends AppController{

Non-prefix routing seems fime. The plugins are added in bootstrap.php like this:

Plugin::load('Contacts', ['bootstrap' => false, 'routes' => true]);

In plugins routing file:

<?php
use Cake\Routing\Router;

Router::plugin('Contacts', function ($routes) {
    $routes->fallbacks('InflectedRoute');
});

Router::plugin('Contacts', function ($routes) {
    $routes->prefix('admin', function ($routes) {
        $routes->fallbacks('InflectedRoute');
    });
});

In Apache the app is setup as an alias with mod rewrite - both on WAMP and on the CentOS server:

http://server-or-localhost/myapp/

Differences between local and server:

  • Server is Linux, uppercase/lower case issues?
  • Same PHP versions, but maybe some modules missing on server PHP?
  • The server redirects http to https
1
In most cases it's a case-sensitivity issue, so you'll have to show the involved controller file contents and names. Also whenever receiving errors, please always post the complete error, that is, including the full stacktrace (ideally copied from the logs where it is available in a properly readable fashion), and a screenshot of the error page as it may contain further details.ndm
Looking at the error page, does your controller namespace/class/filename look like the example that is being shown there?ndm
Yes, it does - added it above.user95437
And does the path/filename match? And are you sure that you've deployed the file? If both is true, then check whether the permissions allow the server/PHP to read the file. Also try redumping the autoloader on the new server.ndm
Path/filename matches I believe - I pasted the path from the error message and the file was there. So I think that confirms the file is deployed. Permission is fine. It's CakePHP 3.2 and PHP 7.user95437

1 Answers

0
votes

Blast! Check your CakePHP version 3.2.0 has this bug. Fixed in 3.2.1.

https://bakery.cakephp.org/2016/01/30/cakephp_3110_and_321_released.html

It's working now.