Welcome Guest, Not a member yet? Register   Sign In
Organizing the Application Controllers
#1

[eluser]Xeoncross[/eluser]
Organizing the applications directory into the default:

APPDIR
->controllers
-->module1
-->module2
-->module3
->models
-->module1
-->module2
-->module3
->views
-->module1
-->module2
-->module3

is more messy in large projects than:

APPDIR
->modules
-->module1
---->controllers
---->models
---->views
-->module2
---->controllers
---->models
---->views
-->module3
---->controllers
---->models
---->views

How can I expect to build a simple drop-in-place "posts" module or "twitter feed" module if the code and views are spread around in different folders? I want to propose a re-write of the codeigniter.php file to something more like this that will allow users to build there site either way.

Code:
<?php

//...


// Load the local application controller
// Note: The Router class automatically validates the controller path.  If this include fails it
// means that the default controller in the Routes.php file is not resolving to something valid.


/* CHANGED!!!!
if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT))
{
    show_error('Unable to load your default controller.  Please make sure the controller specified in your Routes.php file is valid.');
}

include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT);
*/


//If the structure is module based
if (file_exists(APPPATH.'modules/'. $RTR->fetch_module(). '/controllers/'
    . $RTR->fetch_directory(). $RTR->fetch_class().EXT)) {
    
    include(APPPATH. 'modules/'. $RTR->fetch_module(). '/controllers/'
        . $RTR->fetch_directory().$RTR->fetch_class().EXT);

//Else it must be the default CI structure
} else {
    if (!file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT)) {
    //show_error('Unable to load your default controller.  Please make sure the controller specified in your Routes.php file is valid.');
        show_error('Unable to load the '. $RTR->fetch_class(). ' controller. '
        . 'Please make sure the controller specified in your Routes.php file is valid.');
    }
    include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT);
}

//...

?>

Does anyone else think this is a better way to organize the system? ;-)


Messages In This Thread
Organizing the Application Controllers - by El Forum - 07-19-2008, 10:20 PM
Organizing the Application Controllers - by El Forum - 07-19-2008, 10:31 PM
Organizing the Application Controllers - by El Forum - 07-19-2008, 10:40 PM
Organizing the Application Controllers - by El Forum - 07-19-2008, 10:40 PM
Organizing the Application Controllers - by El Forum - 07-19-2008, 11:09 PM
Organizing the Application Controllers - by El Forum - 07-21-2008, 06:42 AM
Organizing the Application Controllers - by El Forum - 07-21-2008, 06:46 AM
Organizing the Application Controllers - by El Forum - 07-21-2008, 06:54 AM
Organizing the Application Controllers - by El Forum - 07-21-2008, 07:27 AM
Organizing the Application Controllers - by El Forum - 07-21-2008, 07:42 AM
Organizing the Application Controllers - by El Forum - 07-21-2008, 07:44 AM
Organizing the Application Controllers - by El Forum - 07-21-2008, 07:48 AM
Organizing the Application Controllers - by El Forum - 07-21-2008, 07:54 AM
Organizing the Application Controllers - by El Forum - 07-21-2008, 07:55 AM
Organizing the Application Controllers - by El Forum - 07-21-2008, 08:04 AM
Organizing the Application Controllers - by El Forum - 07-21-2008, 08:24 AM
Organizing the Application Controllers - by El Forum - 07-21-2008, 08:29 AM
Organizing the Application Controllers - by El Forum - 07-21-2008, 08:36 AM
Organizing the Application Controllers - by El Forum - 07-21-2008, 08:44 AM
Organizing the Application Controllers - by El Forum - 07-21-2008, 08:55 AM
Organizing the Application Controllers - by El Forum - 07-21-2008, 09:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB