douyi3767 2012-09-18 13:16 采纳率: 0%
浏览 12

YII后端实现

I have created frontend-backend structre following http://www.yiiframework.com/wiki/33/ so my structure is

wwwroot/
    index.php
    backend.php
    assets/
    images/
    js/
    protected/
        config/
            main.php
        components/
        controllers/
        models/
        modules/
        views/
        runtime/
        backend/
            config/
                main.php
            components/
            controllers/
            models/
            modules/
            views/
            runtime/

and my backend config is

$backend = dirname(dirname(__FILE__));
$frontend = dirname($backend);
yii::setPathOfAlias('backend',$backend);
return array(
    'basePath' => $frontend,
    'controllerPath' => $backend.'/controllers',
    'viewPath' => $backend.'/views',
...
    'import'=>array(
    'backend.modules.rights.*',
    'backend.modules.rights.components.*',
    'backend.models.*',
    'backend.components.*',
    'application.modules.user.models.*',
    'application.modules.user.components.*',
),...

Now I need to access controllers,models and views at backend from frontend like backend.php/discussion and discussion is at protected/controllers/DiscussionController which right now only accesable from index.php/discussion

One Solution is set 'controllerPath'=>$frontend.'/controllers' but now i loose backend controllers. So is there is way that when i call a controller, first it looks in backend controllers and then look in frontend controllers(in case not found in backend controllers)?

  • 写回答

1条回答 默认 最新

  • drsxzut183207938 2012-11-07 15:01
    关注

    Personally, I like to keep backend (with secure login) totally separate to front-end, ie: completely different project. In this way, your backend can be accessed using a hidden sub-domain like hidden-admin.my-domain.com

    If you want to share code then, as you've mentioned above, use components or widgets.

    评论

报告相同问题?

悬赏问题

  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线