Part of the EllisLab Network
   
 
back-end and front-end separation
Posted: 04 March 2008 05:25 PM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  136
Joined  02-16-2008

Right now I have two separate directories:

system/admin
system/application

And in ‘public_html’ two files to call them:

public_html/admin/index.php
public_html/index.php


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

Profile
 
 
Posted: 04 March 2008 06:55 PM   [ Ignore ]   [ # 1 ]  
Grad Student
Rank
Total Posts:  57
Joined  11-09-2007

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.

 Signature 

If you realized how powerful your thoughts are, you would never think a negative thought.

Profile
 
 
Posted: 04 March 2008 09:36 PM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  716
Joined  06-07-2007

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.

 Signature 

CodeExtinguisher
Download: codex2_rc14.2.zip - 219 KiloBytes of Gloriousness!
Demo: Public preview - login with preview:preview
Temporary Docs: PBWiki

Profile
 
 
Posted: 05 March 2008 05:46 AM   [ Ignore ]   [ # 3 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2405
Joined  06-11-2007

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.

 Signature 

Blog | Twitter | GitHub
————————-
CodeIgniter Base Classes: Keeping it DRY
————————
PyroCMS - open source modular CMS built with CodeIgniter
CleverAndy - get money for un-used concept designs
————————
Libraries: Asset, Cache, cURL, CLI, REST, Template

Profile
 
 
Posted: 05 March 2008 06:36 AM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  741
Joined  09-01-2007

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.

 Signature 

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

Profile
 
 
Posted: 05 March 2008 11:13 AM   [ Ignore ]   [ # 5 ]  
Lab Assistant
RankRank
Total Posts:  136
Joined  02-16-2008

@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”?

Profile
 
 
Posted: 05 March 2008 11:27 AM   [ Ignore ]   [ # 6 ]  
Moderator
Avatar
RankRankRankRankRank
Total Posts:  2791
Joined  01-07-2008

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.

 Signature 
Profile
MSG
 
 
Posted: 05 March 2008 11:37 AM   [ Ignore ]   [ # 7 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  529
Joined  06-16-2006

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.

 Signature 

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

Profile
 
 
Posted: 05 March 2008 06:34 PM   [ Ignore ]   [ # 8 ]  
Research Assistant
RankRankRank
Total Posts:  917
Joined  07-10-2006
Zacharias Knudsen - 05 March 2008 11:37 AM

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.

application/
application/admin/modules/
application/config/
application/controllers/
application/helpers/
application/hooks/
application/language/
application/models/
application/modules/
application/plugins/
application/views/

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.

Profile
 
 
Posted: 21 April 2008 07:18 PM   [ Ignore ]   [ # 9 ]  
Summer Student
Total Posts:  18
Joined  02-18-2008

When I work on my localhost I have this folders:
D:\proyects\proyect1\
-frontend
-backend
-system
-www
—index.php
—admin
—-index.php

D:\proyects\proyect2\
-frontend
-backend
-system
-www
—index.php
—admin
—-index.php
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

Profile
 
 
Posted: 21 April 2008 07:21 PM   [ Ignore ]   [ # 10 ]  
Lab Assistant
RankRank
Total Posts:  136
Joined  02-16-2008

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

Profile
 
 
Posted: 21 April 2008 09:00 PM   [ Ignore ]   [ # 11 ]  
Summer Student
Total Posts:  18
Joined  02-18-2008

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

Profile
 
 
Posted: 21 April 2008 09:02 PM   [ Ignore ]   [ # 12 ]  
Summer Student
Avatar
Total Posts:  28
Joined  01-30-2008

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)

Profile
 
 
Posted: 21 April 2008 09:10 PM   [ Ignore ]   [ # 13 ]  
Summer Student
Total Posts:  18
Joined  02-18-2008

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

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 721, on January 06, 2010 09:38 AM
Total Registered Members: 114983 Total Logged-in Users: 55
Total Topics: 122429 Total Anonymous Users: 3
Total Replies: 647264 Total Guests: 482
Total Posts: 769693    
Members ( View Memberlist )