php - Which comes first, the framework or the application? Dynamic framework and application folders -
OK, so I'm building an MVC framework in PHP and I should be very flexible. It's all right - I'm working on this at the moment and things are going well (so I do not want to use Zend or any other pre-existing structure), but I make both settings and applications Wanted was quite dynamic I try to explain:
This is a simplified directory structure:
- index.php (depending on the domain name, app 1 or app 2 Wants to use) - / App1 (wants) Framework 1.1 To use) - / config - config.php - / app2 (wants to use frame 1.2) - / config - config.php - /framework_1.1 - /framework_1.2 < P> A bootstrap file /index.php receives all incoming requests, after which it /app1/config/config.php or / Say, the config file will load a certain application from app2 / config / config.php , etc. .. HTTP Host: // /index.php switch ($ _SERVER ['HTTP_HOST']) {case 'localhost': $ app_root = ROOT 'APP1 /'; break; Case 'site.com': $ app_root = Route 'APP2 /'; break; Default: $ app_root = Route 'application /'; break; } Define ('APP_ROOT', $ app_root); The bootstrap file then loads the application's config file:
// / include index.php (aptot.config / config.php '); A $ config array will be returned from the application's config file, which will tell where the framework file is located.
// / app2 / config /config.php $ config ['framework_root'] = '/framework_1.2/'; Bootstrap runs that framework Include
// / index.php ($ config ['framework_root']. 'Config / bootstrap.php'); Is this the best way to go about this?
The only problem with this is that the /index.php file is for all possible applications to learn about, so that users /index.php (or the /apps.php file will need to edit the switch statement which may include / Index.php ?).
In addition to loading files from the framework, before is loading, which makes me feel a bit weird ...
The easiest way to specify that request specifies the application, and which app specifies to use the framework, or the easiest way to do it?
Sorry if this was confusing! I am confused by writing a little bit;)
I use most of the time, When I answer your questions, I will:
Is there an easy way to do this, so that the request specifies
multiple "index.php "Use (or use combo with ? App = xxx ) to make things a little cleaner.
In addition to loading the configuration files of the application before loading the files of the framework, which makes me feel a bit weird ...
It's not weird, you must first configure and start some states before you bootstrap your framework, but perhaps you can set your bootstrap to your framework to determine what to do during the bootstrapping of the framework. Each of the sub-class of Rg.
I suggest you to know how they moderate / manage libraries and dependencies. Seriously, there is no reason to write any other structure, but to contribute to an existing one - unless you share them with similar parables.
Comments
Post a Comment