Note that there are some explanatory texts on larger screens.

plurals
  1. POBest Way to Organize PHP Class Hierarchy
    primarykey
    data
    text
    <p>I've got a somewhat primitive framework I've been using for most of my projects, but a general design issue came to mind that I haven't been able to work out yet. For a given application, should I separate the application-specific class structure from the framework's structure, or is building on top of the framework not such a bad thing?</p> <p>For example, say I had a framework with a base Controller class and extended it for a given part of my application. Which arrangement makes the most sense, and why?</p> <p><strong>Class Structure A:</strong></p> <ul> <li>Intuitive, easy to find source files when debugging.</li> <li>File naming/directory structure mirrors class heirarchy.</li> </ul> <pre> - Framework_Control "Framework\Control.php" - Framework_Control_Index "Framework\Control\Index.php" - Framework_Control_Home "Framework\Control\Home.php" - Framework_Control_Contact "Framework\Control\Contact.php" - Framework_Control_About "Framework\Control\About.php" </pre> <p><strong>Class Structure B:</strong></p> <ul> <li>Keeps framework modular and easily to replace/update.</li> <li>Adds some complexity to directory structure, directory/file naming no longer follows class heirarchy all the time.</li> </ul> <pre> - Framework_Control "Framework\Control.php" - Application_Control_Index "Application\Control\Index.php" - Application_Control_Home "Application\Control\Home.php" - Application_Control_Contact "Application\Control\Contact.php" - Application_Control_About "Application\Control\About.php" </pre> <p>I know overall it's going to come down to personal preference, but I want to make sure I weigh out all the pros and cons before I decide which way to go. It really comes down to class naming and directory structure as the actual hierarchy would remain the same in either case.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload