Several popular CMS's for example Drupal, Wordpress, etc. come with an index.php file that's virtually empty aside from a include/require statement which includes another PHP file (as with one file) that contains all the bootstrap code for that Content management systems. What's the rationale with this? Why don't you just move all the bootstrapping code into index.php if it's not doing anything apart from such as the bootstrapping code anyway?
I am attempting to develop a Content management systems for example project to enhance my PHP abilities, and Let me know very well what design factors brought them to get it done by doing this. I realize the advantage of splitting up programs into multiple files, but I have never heard about creating a file that does only include a different one. Clearly there's some benefit, since many major Content management systems projects designed it by doing this, however i cannot determine what it's.
Can someone show me the reasoning with this?
I'd say this really is good design since you can easily change the road to the bootstrap, which causes it to be super easy to alter location from the Content management systems, when necessary.
One other good reason is you might be managing a dev Content management systems while developing, and unveil new versions with one path alternation in the index.php.
Appearance mostly. You'll have a neat and clean directory structure (outdoors of webroot), by which bootstrapping files are separated from index.php file. You will find most likely a number of them (versus. one index.php file) and they're doing various things (db init, authorisation).
I additionally found a couple of Content management systems which begin in debug declaration (to be able to switch display errors and alerts before including any files, so that you can have your errors printed before php features a file with syntax error, but that is not just a sound practice).
In Drupal's situation, you will find other files that perform a similar bootstrap. These typically aren't normal pages, but do serve important reasons. Off the top my mind
install.php do that. I personally use the bootstrap process at the outset of custom import scripts, in addition to scripts that will get known as by
cron that I'd rather not make use of a
I'm able to think about two reasons:
When utilizing an item like Wordpress, you sometimes finish up adding user hacks towards the front controller - say, setting custom constants, specific redirects, or perhaps an additional layer of access control, or whatever. A clear index file enables you to definitely include that type of stuff without disturbing the product's original code.
Getting my way through another bootstrap produces the potential of moving all code (such as the bootstrap) to some location outdoors the net root, and can include it after that.