Welcome Guest, Not a member yet? Register   Sign In
Conceptual and organisation question between Frontend and Backend
#1

[eluser]Référencement Google[/eluser]
Hi,

I would like to discuss about how is the best way to organize things and if you can tell me if the way I am doing things is good or if we can do better.

I actually organize the controllers between admin and frontend like that:

Code:
/Controllers
+- /admin
|  |- rates.php
|  |- page.php
|  |- gallery.php
|- rates.php
|- page.php
|- contact.php
|- gallery.php

As you can see, I have the same name of controllers for the frontend and backend, and each of them do a different job. All controllers (both front and back) are extending a MY_Controller library.

Is my way to organise things is good, or do you advice me to do things differently ?
#2

[eluser]sikkle[/eluser]
Hi elite,

maybe i'm wrong but i handle this kind of stuff by having two different application

/application/admin
/application/pub

This give me also the opportunity to have difference config file, also different hooks.

Also i usually take this setup to be able to put my admin.php (index.php renamed) with .htacccess accept connexion from known IP for security.

Hope this open your discussion and maybe give you idea.

A bientôt!
#3

[eluser]xwero[/eluser]
@sikkle : instead of doing

/application/admin
/application/pub

You could do

/system/admin
/system/pub

And change the application folder in your two bootstrap files.

As for the topic question i think it's a common file structure for small applications. Not much configuration needed so it's very practical.
#4

[eluser]Référencement Google[/eluser]
I first time see this way to do Sikkle, it's far from idiot, but we may have to discuss pros and cons about how you handle your admin.

A bientôt (I am not so much on IRC now, again in a rush time) ;-)
#5

[eluser]sikkle[/eluser]
good to see you get work again Smile

and ya ya, this is two entire separate application, so indeed at some level some may talk about code duplication, i think it's personnal choice indeed.

see ya around soon.
#6

[eluser]nmweb[/eluser]
It works fine although you need to cover for shared resources. I only want to write my models once so there should be a shared folder for models and system isn't really the place
#7

[eluser]esra[/eluser]
You can also do this:

Code:
application/
application/admin/
application/admin/config/
application/admin/hooks/
application/admin/language/
application/admin/models/
application/admin/plugins/
application/admin/views/
application/config/
application/hooks/
application/language/
application/models/
application/plugins/
application/views/
system/
.htaccess
admin.php
index.php

The advantage here is that multiple applications could still exist by creating folders for them under application/, each with its own admin.

Is it possible to use include() or require() within a CI model file? Never tried it, but someone might try creating a file called something like user_proxy_model.php in admin/models/ and try to include or require a model file from the frontend using BASEPATH.application/models/user_model.php. Then try to load the proxy file from a controller to see if the actual model loads or an error occurs.

An alternate approach would be to extend Loader.php (MY_Loader.php) and overload the model() method to search for models across multiple paths.

---
I myself use Matchbox, but do include an admin/ subfolder under controllers/ for most modules. I prefix the filenames with admin which looks ugly in the file system, but the class names look nice using Camelcase (e.g., Article for a frontend controller and AdminArticle for a backend controller.




Theme © iAndrew 2016 - Forum software by © MyBB