Welcome Guest, Not a member yet? Register   Sign In
Help me for Avoid Name Collision and Admin Panel
#1

Hi..
I have new project and This time I want to avoid name collision..

For example My controller name "Site" instead of i want "Site_Controller" or "SiteController" What can I do for this.

And Second Thing How I Separate Admin Panel..
For example i want

mydomain.com // front end
admin.mydomain.com // for backend

Suggest me...
Reply
#2

(This post was last modified: 04-27-2015, 02:16 PM by cartalot.)

this gets down to personal preferences, but i like describing what the controller does or is in charge of.
Sitepages, Contact, Userlogin. if it's something like "search" then be specific Sitesearch, Productsearch, Articlesearch, Customersearch, etc
also i would try and avoid naming things Site_controller, or User_model. The controllers are always in the controller folder so it doesn't need to say controller,
and controllers call models so you don't need the word "model" or "_m" in the model name. The models are the resources that the Controller is working with.
Those model resources can do things like apply business logic - but they are always going to return a message or data back to the controller.
Reply
#3

I agree this is a preference thing.

I actually name things with a single letter suffix. So controllers are _C, models _M, libraries _L.

Otherwise I was ending up with a controller, model and library which all needed to be the same (or similar) name. So rather than have a Login controller, an Auth model and a User library - I can use the same name and know exactly which item I'm calling. And it's only two extra characters.

So now I can have Auth_C, Auth_M and User_L - suits my needs, but might not be the ideal way for everyone.
Reply
#4

I am not starting debate here.. Every one have different thought. I want solution How i do with ci.3.0 because I always use model name clear.. Like 'article'. so i want to name my controller like ArticleController or Article_Controller.
Reply
#5

(This post was last modified: 04-27-2015, 11:15 PM by Athov. Edit Reason: Link )

you can use Routing to do this by
$route['site'] = 'Site_Controller';
or
$route['site'] = 'SiteController';

the only problem is that it can be accessed by "site" AND "Site_Controller"
Reply
#6

I found Simple Solution I think is usefull for many persons..

I am using codeigniter's moduler extention(HMVC);

just add bellow config line in application/config/config.php
Code:
$config['controller_suffix'] = "Controller";//for SampleController
or
$config['controller_suffix'] = "_controller"; //for Sample_controller;

Super easy Wink
Reply




Theme © iAndrew 2016 - Forum software by © MyBB