I am starting a new project and want things to be done right:
Controller:
file name: routemanagerdashboard.php
class name: RouteManagerDashboard
Views:
file name: routemanagerdashboard_dashboard.php
Model:
file name: routemanagerdashboard_model
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is fine, but
routemanagerdashboardseems a bit verbose, you may consider coming up with something shorter. If you like the controller class name but hate the long urls, you can always use a route to get around it.Since we’re dealing with PHP, case sensitivity is not an issue, so your controller class name is fine, just as long as it matches the characters in it’s file name. Just stick to lowercase file names.
Your model name is using the common CI convention, but be aware that when loading the model you may use the second parameter to alias the class name for easier use. Example:
On views: It’s probably better to create a subdirectory for all views that are directly related to the controller. You are probably going to need more than just one view file per controller. You will see your
/viewsfolder become unmaintainable if you put all view files directly in the root of it. I suggest you use sub directories and short meaningful file names, perhaps matching the name of the controller method you intend to load them in. Example:So, yes – you’re Doing it Right for the most part, but coming up with shorter names if possible, and organizing your view files into subdirectories will probably be a good idea.