- 浏览: 13746610 次
- 性别:
- 来自: 洛杉矶
文章分类
- 全部博客 (1994)
- Php / Pear / Mysql / Node.js (378)
- Javascript /Jquery / Bootstrap / Web (435)
- Phone / IOS / Objective-C / Swift (137)
- Ubuntu / Mac / Github / Aptana / Nginx / Shell / Linux (335)
- Perl / Koha / Ruby / Markdown (8)
- Java / Jsp (12)
- Python 2 / Wxpython (25)
- Codeigniter / CakePHP (32)
- Div / Css / XML / HTML5 (179)
- WP / Joomla! / Magento / Shopify / Drupal / Moodle / Zimbra (275)
- Apache / VPN / Software (31)
- AS3.0/2.0 / Flex / Flash (45)
- Smarty (6)
- SEO (24)
- Google / Facebook / Pinterest / SNS (80)
- Tools (22)
最新评论
-
1455975567:
xuezhongyu01 写道wocan23 写道我想问下那个 ...
Mysql: LBS实现查找附近的人 (两经纬度之间的距离) -
xuezhongyu01:
wocan23 写道我想问下那个111.1是怎么得来的我也看不 ...
Mysql: LBS实现查找附近的人 (两经纬度之间的距离) -
18335864773:
试试 pageoffice 在线打开 PDF 文件吧. pag ...
jquery在线预览PDF文件,打开PDF文件 -
青春依旧:
opacity: 0.5; 个人喜欢这种方式!关于其他css特 ...
css透明度的设置 (兼容所有浏览器) -
July01:
推荐用StratoIO打印控件,浏览器和系统的兼容性都很好,而 ...
搞定网页打印自动分页问题
Create an Admin panel with CodeIgniter
As I see it there are three methods to creating an admin system using the MVC framework CodeIgniter . In this article I will show examples of the structures for each and mention the pro's and con's of using each.
This article will only outline the theory and suggest the structures to you. I do not plan on writing yet another "How to make a user login system and add admins to it" type article.
1.) Two applications
In CodeIgniter you can easily set up multiple applications to run off the same CodeIgniter install, simply by creating a copy of index.php and renaming it to something else.
/ applications/ frontend/ controllers/ home.php blog.php comments.php models/ blog_model.php comment_model.php views/ blogs/ index.php view.php comment/ view.php index.php backend/ config/ controllers/ dashboard.php blog.php comments.php models/ blog_model.php comment_model.php views/ blogs/ index.php form.php comment/ index.php dashboard.php login.php system/ index.php admin/ index.php
Here you can see I have put index.php into an admin/ folder of its own. Both index.php files will point to a single folder within /applications and this can be done by setting:
index.php
$application_folder = "applications/frontend";
admin/index.php
$application_folder = "applications/backend";
This method does work, but is only really any good for big sites that have very different content for their front and back ends. You cannot use the same libraries, helpers, models, etc which will mean its very easy to end up with duplicated code. I'm not a big fan of such frontend/backend separation as for most sites, an admin panel will use the same models and code but this varies entirely on the spec of the site you are building.
2.) Sub-directories
This method follows a more usual CodeIgniter set-up and is the way that most new CodeIgniter users will try things at first.
/ application/ config/ controllers/ admin/ blog.php comments.php blog.php comments.php models/ blog_model.php comments_model.php views/ admin/ blog/ index.php form.php comments/ index.php form.php dashboard.php login.php blog/ index.php view.php comments/ view.php system/ index.php
Here we are keeping the default MVC structure of CodeIgniter and using sub-directories for our controllers to give us the http://example.com/admin/blog URL structure. This method has the advantage of being able to share models, libraries and helpers across both the front and backend. If you really need to separate models for front and back ends, why not just have a models/admin/ folder and put them in there?
The down side is that when your site expands and more controllers are required, it can be a real pain to have your content so loosely linked across the entire application directory. You can see in the example above that we have several folders for blog and comment content, where really we should only have one. This one folder is called a module...
3.) Modules
To keep all the content under one single folder we can adopt the HMVC approach. This stands for Hierarchal MVC which essentially is just modular CodeIgniter. Two systems have been developed for this: HMVC and Matchbox . I personally prefer use the latter but have never tried HMVC so i'll leave that one up to you.
A strange thing that many CodeIgniter users seem to do is create a blog module, comment module and admin module. This strikes me as a very strange separation of content that goes against the point of using modules in the first place! I have a single admin.php controller in the main controllers folder to act as the default admin page which will handle login, logout and the main dashboard. Then I add another admin.php controller in each module and use URI Routing to get my URL structure as http://example.com/admin/.
/ application/ config/ controllers/ admin.php modules/ blog/ controllers/ admin.php blog.php models/ blog_model.php views/ admin/ index.php form.php comments/ controllers/ admin.php comments.php models/ comment_model.php views/ admin/ index.php form.php views/ admin/ dashboard.php login.php system/ index.php
Right now to get at the blog admin you would have to go to http://example.com/blog/admin which may well be fine with you. If not, you can add the following routes to your application/config/routes.php to swap the segments around and emulate a /admin/ folder.
$route['admin/([a-zA-Z_-]+)/(:any)'] = '$1/admin/$2'; $route['admin/login'] = 'admin/login'; $route['admin/logout'] = 'admin/logout'; $route['admin/([a-zA-Z_-]+)'] = '$1/admin/index'; $route['admin'] = 'admin';
This way you have your admin controllers kept with the frontend controllers, you are sharing models, libraries and helpers and you still have some nice URL's.
Summary
If your front and back end applications share nothing in common and never will do, use method #1. If you have a small site with one a few controllers and do not want the small overhead HMVC adds, use method #2. If you are working on a massive site that is modular and shares code between front and back ends, use method #3.
Got any more methods to handle admin structures? Let me know in the comments.
发表评论
-
CakePHP你必须知道的21条技巧
2012-10-19 06:25 1886原文链接:http://www.avatarfinancial ... -
cakephp 1.3 Views
2012-10-09 06:12 1444Section 1 Views 视图 一个vie ... -
cakephp 1.3 Models
2012-10-09 06:07 2502Section 1 What is a model? ... -
cakephp 1.3 Controller
2012-10-09 05:49 3335Controller 一个controller用于管理 ... -
cakephp 1.3 配置CakePHP
2012-10-09 05:31 4647Section 1 数据库配置 app/config/ ... -
CakePHP 2.x十分钟博客教程
2012-10-07 01:27 244201. CakePHP2十分钟博客教 ... -
Codeigniter Grid 使用方法 (flexigrid)
2010-05-23 02:05 2819来源:http://codeigniter.com/forum ... -
CI集成 ckeditor 配置
2010-05-23 01:34 3754配置 ckeditor 1.上传 下载 ckedito ... -
codeigniter 辅助函数 - 敏感词过滤
2010-05-05 06:18 4578我们都知道有些敏感的词汇是不适合出现在互联网上的,特别是在有用 ... -
实现简单 codeigniter 缓存 (cache)
2010-04-30 23:47 5282代码 class Test extends Contr ... -
CKEditor Helper for CodeIgniter
2010-04-19 00:37 3981Using CKEditor as a plugin in y ... -
codeigniter 生成 excel
2010-04-19 00:33 3329Excel Plugin Th ... -
CakePHP 中文手册
2010-04-14 21:04 2343基本概念 Section1 简介 ... -
利用 Cache_Lite代替codeigniter中的cache功能
2010-01-29 06:15 5516codeigniter的功能纵然强大,也有不足之处。其cach ... -
CodeIgniter 操作PDF ( Generating PDF files using CodeIgniter )
2010-01-03 04:03 3611PDF files rock! Some of the p ... -
CodeIgniter 合作 Authorize.net
2009-12-30 00:25 1617function payment(){ // 略... ... -
CodeIgniter 合作paypal
2009-12-30 00:15 2356<?php class Paypal extend ... -
CodeIgniter 操作 CSV
2009-12-29 07:17 4645A Comma separated values (CSV) ... -
codeigniter 操作 Rss
2009-12-29 07:12 1978I wrote a codeigniter library t ... -
codeigniter操作xml
2009-12-29 06:57 3996This Simplexml class provides a ...
相关推荐
CodeIgniter-admin-panel, 使用 Twitter Bootstrap的管理员面板的CodeIgniter模板 CodeIgniter-Sample-Project使用 Twitter 2.1.2和 Bootstrap的示例管理员面板。我想让大家知道,想法是接受建议,并且随着社区的...
"CodeIgniter-Admin-Panel"项目是基于这个框架创建的一个后端管理面板。这个管理面板使用了CodeIgniter 3版本,它是CodeIgniter的一个稳定版本,提供了许多优化和改进,包括更好的性能和增强的安全性。 在描述中...
Vue-element-admin 和 PHP CodeIgniter 是两种非常流行的开源框架,分别用于前端开发和后端构建。这个名为 "RES-vue-php-admin" 的压缩包显然整合了这两种技术,旨在创建一个全面的后台管理系统。 Vue-element-...
Codeigniter-php-Bootstrap-Admin-Panel和用户管理 具有用户管理功能的Codeigniter Bootstrap管理面板 Bootstrap是最流行HTML,CSS和JS框架,用于在Web上开发响应式,移动优先项目。 它是为自定义CodeIgniter项目...
SatSun CRMS beta0.1(for CodeIgniter) SatSun CRMS beta0.1(with CodeIgniter) SatSun CRMS beta0.1(for CodeIgniter) SatSun CRMS beta0.1(with CodeIgniter)
"CodeIgniter 2.1.2"是该框架的一个特定版本,它在2012年发布,虽然现在已经有了更新的版本,但这个老版本仍然被许多开发者用于维护旧项目或者教学用途。 CodeIgniter基于Model-View-Controller(MVC)设计模式,这...
这个“codeigniter使用例程 网站跳转管理系统”是一个基于CodeIgniter的简单应用,它利用MVC(模型-视图-控制器)设计模式来组织代码结构。下面我们将详细探讨这个例程中的关键知识点。 1. MVC架构: MVC是一种...
element-admin 和 PHP CodeIgniter RESTful 实现,采用前后端分离架构的权限管理系统,PHP快速开发平台,目标是搭建一套简洁易用的快速解决方案,可以帮助用户有效降低项目开发难度和成本。以vue-element-admin@...
Loosely based on the Model-View-Controller pattern, CodeIgniter is an open source framework for application development. It allows you to develop projects by providing a rich set of libraries for ...
PHP框架之CodeIgniter留言板实例PHP框架之CodeIgniter留言板实例PHP框架之CodeIgniter留言板实例PHP框架之CodeIgniter留言板实例PHP框架之CodeIgniter留言板实例PHP框架之CodeIgniter留言板实例PHP框架之CodeIgniter...
在这个"codeigniter的简单示例"中,我们将深入探讨CodeIgniter的核心概念和基本用法。 1. **MVC架构**: MVC是软件设计中的一个经典模式,用于分离业务逻辑、数据处理和用户界面。在CodeIgniter中,模型(Model)...
Source Server : mysql_localhot Source Server Type : MySQL Source Server Version : 50624 Source Host : localhost Source Database : codeigniter Target Server Type : MySQL Target Server Version : 50624 ...
以下是对CodeIgniter2.0的一些核心知识点的详细解释: 1. MVC架构:CodeIgniter遵循Model-View-Controller(MVC)设计模式,将业务逻辑、数据处理和用户界面分离,提高代码的可维护性和可扩展性。Model负责处理数据...
这个"codeigniter 代码实例分享"看起来是某个开发者或团队为了展示或分享他们在CodeIgniter上的工作成果,结合了jQuery 1.4、Eclipse IDE的使用经验。 在这些提供的文件中,我们可以看到一些关键组成部分: 1. **...
CodeIgniter以其小巧、高性能、易于使用和配置、不需要命令行、无需新的模板语言、以及简化的编码规则等特点受到开发者的青睐。CodeIgniter的核心思想是减少编码工作量,让开发者能够把精力集中在创新性工作的开发上...
codeigniter-3.2.1-with-admin-LTE-Template-Intigration带有php codeigniter 3.2.1的最新版Admin LTE Templete 从存储库下载代码。 解压缩该zip文件。 打开浏览器; 转到localhost / phpmyadmin。 在该数据库中导入...
《CodeIgniter1.7敏捷框架开发》一书由Jose Argudo Blanco与David Upton共同撰写,由Packt Publishing在2009年11月首次出版。这本书旨在帮助PHP开发者提升编码效率,通过免费、紧凑且开源的MVC框架——CodeIgniter...
本资源提供的"CodeIgniter 2.0 中文手册"是针对该框架的详细指南,帮助开发者更好地理解和运用这个框架。 CodeIgniter的核心设计理念是"简单而强大",它提供了一个优雅的PHP接口,让开发者可以构建功能丰富的Web...
这个压缩包包含的资源对于深入理解和使用CodeIgniter至关重要。以下是对这些资源的详细解析: 1. **CodeIgniter2.2.0中文用户参考手册.CHM**: 这个CHM文件是CodeIgniter 2.2.0版本的中文用户手册,它包含了框架的...