【发布时间】:2015-06-15 17:18:05
【问题描述】:
我正在尝试创建一个plugin,这是我的文件夹布局;
在 bootstrap.php 中
CakePlugin::load('ContactManager');
在 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 {}
联系方式.php
class Contact extends ContactManagerAppModel {}
如何在浏览器中显示 index.ctp index.ctp
<?php echo 'hello'; ?>
请求http://localhost/cakephp/ct/ContactManager/Contacts 给出了缺少控制器错误,而不是我的插件控制器索引:
【问题讨论】:
-
你的截图仍然是
http://localhost/cakephp/ContactsManager/Contacts。由于您创建了一个路由,以便/指向您的插件,因此 urlhttp://localhost/cakephp将指向该控制器操作 如果它没有 意味着更基本的事情是错误的,比如查看错误的应用程序/编辑错误的文件插件未正在加载等 -
Router::connect('/ct/', array('plugin' => 'ContactManager', 'controller' => 'Contacts', 'action' =>'index'));和我的链接:localhost/cakephp/ct/ContactManager/Contacts 它不起作用,:(
-
嗯,这并不奇怪,因为这与您评论中的路线不匹配,也不匹配任何其他路线。这只会导致“缺少 ct 控制器”错误。我推荐你get on irc,因为看起来你有一些误解需要澄清。
-
您已经有了,您的问题不在于创建插件,而在于其他东西。 SO 是这种帮助的错误格式。祝你好运。
标签: cakephp cakephp-2.0