codeigniter separating frontend and backend

2019-08-05 15:22发布

问题:

I've read these pages regarding this:

http://philsturgeon.co.uk/blog/2009/07/Create-an-Admin-panel-with-CodeIgniter

Separate Admin and Front in codeigniter (look at answer by Madmartigan)

their both good approaches but I'm not sure if that is what I'm looking for.

I want to separate the front-end from the back-end I was thinking of a layout like this: (view image) I am about to convert large web applications to CI and to keep everything as organized as possible i figured this folder layout would be the best approach but since im a newbie to CI would you consider this layout? I have attempted this layout already as a test and I would run into problems since the directory is named back-end or front-end so when I would type say:

http://example.com/backend/mycontroller/mymethod I would reach a 404 page. 

回答1:

I was looking into this last week, for a small project I was setting up (in the end I went with Kohana 2.3.4, but never mind :P)

The best file system I came up with for CodeIgniter is this:

/ application
/ - /admin
/ - - /config
/ - - /controllers
/ - - /models
/ - - /views
/ - /public
/ - - /config
/ - - /controllers
/ - - /models
/ - - /views
/ core
/ - /all the core stuff
/ public_html
/ - /admin
/ - - index.php
/ - index.php

The problem here is there's no code-sharing going on between the two, so you can't re-use any stuff - if you're OK with that (probably not good for a large application), this should probably do what you want.

If switching to Kohana is an option, give me a shout and I'll post my structure for that - it's similar to this, but has an extra level where I the front-end and back-end can share code, while still using their specific code as a priority. It's much nicer for anything bigger than a small application :)