doujilou3903 2010-07-19 02:32
浏览 4
已采纳

如何在codeigniter中管理这个项目?

I want to build a project using codeigniter, the project consist of 2 levels, USER level and ADMIN level

I'm now building the ADMIN level, is it the best practice to make all my admin functions in 1 controller? like add/modify/delete users and add/modify/delete admins etc....

or make many controllers everyone has it's job like one for add/modify/delete users and another controller for add/modify/delete admins .. and so on?

I think the second choice is better but then I will have another problem, which is separating my user level controllers from the admin level controllers

  • 写回答

1条回答 默认 最新

  • doufangmu9087 2010-07-19 02:48
    关注

    Personally it all comes down to preference. I prefer the method of creating an admin folder in my controllers folder so accessing my controllers for the admin area happens like so:

    http://www.exampleapp.com/admin/clients
    admin is the folder name in your controllers folder
    clients is the name of the controller within the admin folder
    

    The above URL structure has it's advantages and disadvantages (I prefer it to keep my code clean and less cluttered).

    I tend to also make one model per table in the database. So a model called users would deal with all aspects of the users table in my database. A products model would deal with all aspects of the products database table.

    You're still adhering to the DRY (don't repeat yourself) method because you simply include the model files you need from within your admin controllers depending on what section of the admin you're administering.

    For your users section you could create a folder called users within your controllers folder and use the same above mentioned method.

    Phil Sturgeon (a.k.a God of Codeigniter) summed this up in his blog post, but goes into a little more detail, give it a read: http://philsturgeon.co.uk/news/2009/07/Create-an-Admin-panel-with-CodeIgniter

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

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?