I'm creating a PHP web application framework (MVC). I'd rather not use external libraries or components (as I want this to be purely my work for now)
Can you tell me some tips/guidance for what each of my files should be responsible for doing? Such as, what should be handled by the Framework script and what should be handled by an Application script used in the framework?
I keep changing where different code is written (as I think to myself... "Should this be handled by the framework or by each application?"), which is making it more confusing as I go along.
I've read a bunch (20...50...100 even!) of tutorials regarding MVC, frameworks etc, but there's not many that explain the ideal 'flow' of a framework..
Currently I have it working like this:
- Main Index (index.php)
- Defines constants (DS = DIRECTORY_SEPARATOR, PS = PATH_SEPARATOR, etc)
- Sets include paths (ROOT . '/classes', ROOT . '/includes', etc)
- Loads Framework configuration file (config.php)
- Sets up framework class autoloader (__autoloader())
- Sets up some sort of Core object (Core::init($config)?)
- Loads Application index.php file (app/index.php)
- Configuration (config.php)
- Defines config array ($config)
- Configures config array ($config['debug'] = 0... or something like that..)
- Application Index (app/index.php)
- Defines constants (APP_CONTROLLERS, APP_MODELS, etc)
- Sets include paths (APP_PATH . '/classes', APP_PATH . '/includes', etc)
- Loads Application configuration file (app/config.php)
- Application Configuration (app/config.php)
- Defines config array ($app_config)
- Configures config array (Same sorta stuff as the other config, but for App)
Now.... do I seem to be heading in the right direction? And what sort of things should the Framework's Main Index script be doing rather than the App Index? Should the Main index just initiate some stuff and pass off most of the work to the App Index, which will set up routers etc to route URLs to controllers, etc...? Or should the Framework be creating routers and initiating controllers, and the App would just set controller paths and some rules, etc..?
I understand what Controllers do, and models/views etc (I'll cross those bridges when i come to them later on), but for now I just want to get the basic things flowing correctly from the right places so things later on will work well.
At the moment, my head's about to explode! haha
This may have even been a really dumb question, but I just think I need some straight-forward guidance to help me clear things up before I get everything totally out of whack! Any advice would be appreciated.
Thanks =)