Jump to content

Recommended Posts

Not really anything help related, more opinion related. Currently with my framework controllers can only be placed in either the root /controllers directory or in a single subfolder, such as /controllers/admin

 

Is that far enough or should it be unlimited. What I am doing though is following a naming convention for controller class names. Say I had a controller called /controllers/account_settings.php

It's class declaration would look like:

 

class AccountSettingsController extends Controller

When a controller is in a subdirectory, the name of the directory must also be prepended to the class name. So if the controller is now /controllers/members/account_settings.php the class declaration would be:

 

class MembersAccountSettingsController extends Controller

I did it purely for organization. I figured people wouldn't want/need anything more then 1 level deep, however sometimes they might.

 

So really, what's your take on how far a controller can be nested in the controllers directory. And is my naming convention okay?

Link to comment
https://forums.phpfreaks.com/topic/209898-feature-opinion/
Share on other sites

When a controller is in a subdirectory, the name of the directory must also be prepended to the class name. So if the controller is now /controllers/members/account_settings.php the class declaration would be:

 

That seems a very confusing and limiting method. Most frameworks use the PEAR naming convention which makes it VERY easy to place files wherever you like as long as its on the include path.

 

Controllers, views, and models however are likely to require there locations to be configurable, though I guess it depends on the framework. Some frameworks prefer convention over configuration which usually makes them easier to use. You simply force users to do it your way. However, force to hard, and users will break the rules, hack your framework, or move on to something less restrictive.

Link to comment
https://forums.phpfreaks.com/topic/209898-feature-opinion/#findComment-1095761
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.