Php 分包商不在Yii框架内工作

Php 分包商不在Yii框架内工作,php,yii,yii-modules,Php,Yii,Yii Modules,对于我的项目,我需要通过在“Controllers”文件夹中添加分包商来自定义代码。 例如: 在控制器中我添加了 controllers -> customer -> CustomerDetailsController.php 型号: models -> customer -> Customer.php views -> customer -> customerdetails -> index.php, admin.php, _form.php ..

对于我的项目,我需要通过在“Controllers”文件夹中添加分包商来自定义代码。 例如:

控制器中我添加了

controllers -> customer -> CustomerDetailsController.php
型号:

models -> customer -> Customer.php
views -> customer -> customerdetails -> index.php, admin.php, _form.php .... etc
'urlManager' => array(
                    'urlFormat' => 'path',
                    'showScriptName' => false,
                    'urlSuffix' => '/',
                    //'rules' => $params['url.rules'],
                    //Modified "rules" attribute for hiding index.php and added .htaccess in WebRoot
                    'rules' => array(
                        '<controller:\w+>/<id:\d+>' => '<controller>/view',
                        '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                        '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
                        array('customer/<controller:\w+>/<action:\w+>' => 'customer/<controller>/<action>'),
                    ),
                ),
和视图:

models -> customer -> Customer.php
views -> customer -> customerdetails -> index.php, admin.php, _form.php .... etc
'urlManager' => array(
                    'urlFormat' => 'path',
                    'showScriptName' => false,
                    'urlSuffix' => '/',
                    //'rules' => $params['url.rules'],
                    //Modified "rules" attribute for hiding index.php and added .htaccess in WebRoot
                    'rules' => array(
                        '<controller:\w+>/<id:\d+>' => '<controller>/view',
                        '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                        '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
                        array('customer/<controller:\w+>/<action:\w+>' => 'customer/<controller>/<action>'),
                    ),
                ),
以下是我的
config/main.php
文件:

'import'=>
array(
...
/* Loaded CustomerController model, view and controller */
                'application.controllers.customer.*',
                'application.controllers.models.customer.*',
...
)

URL管理器:

models -> customer -> Customer.php
views -> customer -> customerdetails -> index.php, admin.php, _form.php .... etc
'urlManager' => array(
                    'urlFormat' => 'path',
                    'showScriptName' => false,
                    'urlSuffix' => '/',
                    //'rules' => $params['url.rules'],
                    //Modified "rules" attribute for hiding index.php and added .htaccess in WebRoot
                    'rules' => array(
                        '<controller:\w+>/<id:\d+>' => '<controller>/view',
                        '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                        '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
                        array('customer/<controller:\w+>/<action:\w+>' => 'customer/<controller>/<action>'),
                    ),
                ),
当然,我读过有关模块的内容,但我不想为这个功能实现模块,我希望将其作为一个外部实体

那么如何在整个项目中实现这种结构呢?

这是正确的吗

'application.controllers.models.customer.*',
你确定那是你的类文件的路径吗?可能是这样的:

application.models.Customer

对吧??我认为类名需要大写才能在别名中使用。(文件本身可能是Customer.php,而不是Customer.php)。

最后一个url重写规则不应包装在数组中,即

'customer/<controller:\w+>/<action:\w+>' => 'customer/<controller>/<action>',
“客户//”=>“客户//”,
而不是

array('customer/<controller:\w+>/<action:\w+>' => 'customer/<controller>/<action>'),
array('customer/'=>'customer/'),

此外,您还应确保主控制器文件夹中没有
CustomerController

C'mon模块很酷:)这个错误看起来好像找不到其他类,而不是那个控制器。你试过空动作吗
CustomerDetails
虽然它应该报告
CustomerDetailsController
但您是否尝试了不带“customer”的url,即
../index.php/CustomerDetails/
?如果是,它能起作用吗?@topher:是的,我试过了,但不起作用