Part of the EllisLab Network
   
 
back-end and front-end separation
Posted: 04 March 2008 06:25 PM   [ Ignore ]  
Grad Student
Rank
Total Posts:  43
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 07:55 PM   [ Ignore ]   [ # 1 ]  
Grad Student
Rank
Total Posts:  47
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 10:36 PM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  648
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 06:46 AM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  680
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 

StyleDNA Ltd - CodeIgnitor Web Development, Hosting and Design.
Guru Profile - Hire me
_________________

Helpers: Asset Helper, BBCode Helper
Libraries: Template Lib
_________________

Theres no place like 127.0.0.1

Profile
 
 
Posted: 05 March 2008 07:36 AM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  539
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 12:13 PM   [ Ignore ]   [ # 5 ]  
Grad Student
Rank
Total Posts:  43
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 12:27 PM   [ Ignore ]   [ # 6 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1012
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 

Blog | Twitter | Coffee

Profile
 
 
Posted: 05 March 2008 12:37 PM   [ Ignore ]   [ # 7 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  473
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 07:34 PM   [ Ignore ]   [ # 8 ]  
Research Assistant
RankRankRank
Total Posts:  888
Joined  07-10-2006
Zacharias Knudsen - 05 March 2008 12: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.

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 08:18 PM   [ Ignore ]   [ # 9 ]  
Summer Student
Total Posts:  15
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 08:21 PM   [ Ignore ]   [ # 10 ]  
Grad Student
Rank
Total Posts:  43
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 10:00 PM   [ Ignore ]   [ # 11 ]  
Summer Student
Total Posts:  15
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 10:02 PM   [ Ignore ]   [ # 12 ]  
Summer Student
Total Posts:  16
Joined  01-31-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 10:10 PM   [ Ignore ]   [ # 13 ]  
Summer Student
Total Posts:  15
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 719, on June 06, 2008 10:16 AM
Total Registered Members: 59735 Total Logged-in Users: 17
Total Topics: 71326 Total Anonymous Users: 0
Total Replies: 384400 Total Guests: 332
Total Posts: 455726    
Members ( View Memberlist )