duanjianfu1398 2010-01-27 10:47
浏览 51
已采纳

使CodeIgniter默认使用<ControllerName> _Controller而不更改库?

I'm finding I have lots of conflicts with class names when developing for CodeIgniter. For example, I recently had the situation where I had a Checkout controller:

class Checkout extends Controller 
{
    // Contents
}

And then went on to create a new custom library:

class Checkout
{
    // Contents
}

Which would obviously throw an error.

What I want is to be able to define my controllers as <ControllerName>_Controller so:

class Checkout_Controller extends Controller 
{
    // Contents
}

And I want CodeIgniter to pick this up as it would any other controller. I also want to do this without changing any of the core library so that I can update it without re-implementing my changes again and again.

I know you can do this with routing (and it's how I have been handling it so far) but this seems to me to be more like a hack than an actual solution. Is there a way to force CodeIgniter to use the syntax I want with the restrictions I need?

  • 写回答

1条回答 默认 最新

  • douxi3554 2010-01-27 11:58
    关注

    While this article generally "grinds my gears" it does show you how to the _Controller suffix to your controllers.

    http://net.tutsplus.com/tutorials/php/6-codeigniter-hacks-for-the-masters/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作