I'm trying to create a plugin, this is my folder layout;
in bootstrap.php
CakePlugin::load('ContactManager');
in routes.php
Router::connect(
'/ct/',
array(
'plugin' => 'ContactManager',
'controller' => 'Contacts',
'action' =>'index'
)
);
ContactManagerAppController.php
<?php
class ContactManagerAppController extends AppController {}
ContactsController.php
<?php
class ContactsController extends ContactManagerAppController {
public $uses = array('ContactManager.Contact');
public function index() {
//...
}
}
ContactManagerAppModel.php
<?php
class ContactManagerAppModel extends AppModel {}
Contact.php
class Contact extends ContactManagerAppModel {}
How do I display index.ctp in my browser index.ctp
<?php echo 'hello'; ?>
Requesting http://localhost/cakephp/ct/ContactManager/Contacts
gives a missing controller error, instead of my plugin controller index:
You should be able to access your plugin's Contacts Controller (without setting up routes) from
/contact_manager/contacts
. So by the looks of your question the absolute URL should be:-If this is not working then there's something wrong with the plugin's setup. Make sure the plugin files are readable and that the filenames and classes are all correct. Your plugin structure looks good otherwise.
If the above URL works then (and only then) you can consider re-routing it. To do this you need to do something like this (preferably in
/app/Config/routes.php
):-If the route does not work try checking that nothing is overridding it elsewhere in your routes file.
You should use snake case (e.g. 'contact_manager') not camel case (e.g. 'ContactManager') in your route parameters.