EllisLab text mark
Advanced Search
back-end and front-end separation
Posted: 04 March 2008 07:25 PM
Joined: 2008-02-17
278 posts

Right now I have two separate directories:


And in ‘public_html’ two files to call them:


How do you separate your front-end from back-end? Or do you prefer to keep them together?

Posted: 04 March 2008 08:55 PM   [ # 1 ]   [ Rating: 0 ]
Joined: 2007-11-09
58 posts

What I do is create a controller named admin and put my functions like login, logout, addPost, editPost, etc, and use the session class to verify permissions before loading a view.

Posted: 04 March 2008 11:36 PM   [ # 2 ]   [ Rating: 0 ]
Joined: 2007-06-07
690 posts

the way CodeExtinguisher works is by putting everything it uses in a folder outside of system/...it never made sense to me to have the application inside the system folder.



Posted: 05 March 2008 07:46 AM   [ # 3 ]   [ Rating: 0 ]
Joined: 2007-06-11
2987 posts

Well there are two options really.

Two Applications
Have two applications totally seperate, this means they have nothing in common. Seperate login, seperate models, seperate libraries, etc. That may be useful, depending on what sort of backend you have, as you may have loads of huge big functions and libs that frontend users will never need, or you may not have the same login for both admins and users.

Admin Sub-Directory
If you will need to use lots of similar data/files between both the admin and frontend, it makes sense to just have the admin in a sub directory and use all the same stuff. I normally do it this way as my sites are often basic “user registration/forum/blog” type sites with a few extras. No need to seperate it.


Blog | Twitter | GitHub | BitBucket
PyroCMS - open source modular CMS built with CodeIgniter
PancakeApp - Simple, hosted invoicing/w project management

Posted: 05 March 2008 08:36 AM   [ # 4 ]   [ Rating: 0 ]
Joined: 2007-09-01
820 posts

I keep mine separate by use of admin directly and an Admin and Public Controller. The only different is the Admin controller asks for authentication.


Kaydoo - A day in the life of a developer
BackendPro Control Panel

Posted: 05 March 2008 01:13 PM   [ # 5 ]   [ Rating: 0 ]
Joined: 2008-02-17
278 posts

@jTaby: Now that you mentioned it, it makes logical sense to put an application outside system folder, but does it give you any other benefits besides having things “neat”?

Posted: 05 March 2008 01:27 PM   [ # 6 ]   [ Rating: 0 ]
Joined: 2008-01-07
2540 posts

It means that you can run several applications with only one system folder, which cuts down on the clutter and makes it really easy to update.

Posted: 05 March 2008 01:37 PM   [ # 7 ]   [ Rating: 0 ]
Joined: 2006-06-16
319 posts

You could also use two applications (as the pyromaniac) suggest, together with Matchbox, and have a module directory in your system folder with resources that are to be shared between the two, and then additional module directories in each application folder with resources exclusive to front/back-end.


Best regards. Zacharias.
Matchbox (Modular Separation) | Wick (Controller Loader)

Posted: 05 March 2008 08:34 PM   [ # 8 ]   [ Rating: 0 ]
Joined: 2006-07-10
485 posts
Zacharias Knudsen - 05 March 2008 06:37 PM

You could also use two applications (as the pyromaniac) suggest, together with Matchbox, and have a module directory in your system folder with resources that are to be shared between the two, and then additional module directories in each application folder with resources exclusive to front/back-end.

In the case of Matchbox, could you not modify MY_Router to conditionally load a module from application/admin/modules/ when ‘admin’ was included as the first segment in the url? You could probably enable this as a feature via a config setting. The advantage would be sharing common libraries, helpers, and plugins within a single application rather than creating two applications. The disadvantage, especially when a module installer is considered, is dividing module specific code among two module directory system.


In our earlier projects at work, we use the pyromaniac approach but rename a second copy of index.php to admin.php in order to load the two applications.

Posted: 21 April 2008 10:18 PM   [ # 9 ]   [ Rating: 0 ]
Joined: 2008-02-18
20 posts

When I work on my localhost I have this folders:

Then in the first index.php I have:
  $system_folder = “../system”;
  $application_folder = “../frontend”;

..And in admin/index.php I have:
  $system_folder = “../../system”;
  $application_folder = “../../backend”;

This way when I upload my files to the server I put frontend,backend and system outside the public_html and the contents of www goes into public_html

Posted: 21 April 2008 10:21 PM   [ # 10 ]   [ Rating: 0 ]
Joined: 2008-02-17
278 posts

dejitaru, is there a way to share some libraries or models between font end and back end using your method?

Posted: 22 April 2008 12:00 AM   [ # 11 ]   [ Rating: 0 ]
Joined: 2008-02-18
20 posts

Sharing a library is not a problem, just drop it under the system/libraries nut sharing a model could me a problem. The way I do is copying the model in both models folders

Posted: 22 April 2008 12:02 AM   [ # 12 ]   [ Rating: 0 ]
Joined: 2008-01-31
27 posts

this is what i’ve done and worked for me.
just make 2 controllers, admin and public. then make 2 subdirectories in your /views folder (/views/admin and /views/public)

Posted: 22 April 2008 12:10 AM   [ # 13 ]   [ Rating: 0 ]
Joined: 2008-02-18
20 posts

yes of course Psyco, it just about preferences ^_^ I prefer my client go:
http://www.example/admin instead of http://www.example/admin.php

It may sound perhaps silly… but you should meet my clients! they call me twice a week because of the .php at the end

Posted: 25 July 2011 10:10 PM   [ # 14 ]   [ Rating: 0 ]
Joined: 2011-07-25
1 posts

Hello friends
I am using Code Igniter 2.0.2,
Can anyone tell me how to create a separate admin folder inside application folder.

Many thanks in advance.

Posted: 12 November 2012 03:02 AM   [ # 15 ]   [ Rating: 0 ]
Joined: 2012-11-12
1 posts

Hello all,

If you have problem to separate admin and front-end (modules, template)

Solution is over here, https://github.com/bhuban/modular

Module separation for admin and fron-end using HMVC and template separation using template libraries

I am using two third party libraries, you can find it in zip file.

1. HMVC for modular developed by wiredesignz
2. Template engine for templating by Phil Sturgeon

Just unzip it into your webserver root directory and run

localhost/modular for front-end


localhost/modular/admin for back-end

application/back-modules, it is for the back-end modules

application/front-modules, it is for the front-end modules

templates/admin for the back-end templates
templates/front for the front-end templates

themes/admin for the back-end themes
themes/front for the front-end themes

Nothig hacked in original code just configured using config.php and index.php