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:
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