New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move all "bootstrapping" code to bootstrap.php #371
Comments
Why can't it be swapped where it is? |
The reason is basically that you would have control about the whole bootstrapping process within well.. bootstrap.php (or bootstrap.php loading dispatch.php or whatever at the bottom). The index.php file would only be the entry point for the webserver and nothing else. Edit: benefit would be that we can test for the PHP version before anything else happens (and for extensions). |
It also means that if you upgrade cakephp you have one file less to worry about diffing/merging. |
This was the issue that made me think that index.php should be dumb and bootstrap.php should do some checks at the top before anything else happens: EDIT: if you agree, I would move things around in a test app, see if no issues arise and create a PR. |
Shouldn't
... now be in the middleware as one item (that can simply be disabled in Application.php)? |
I'm not sure it can entirely be middleware as it has to muck with the |
Closing as I think this is 'done'. At the very least it is doable in applications where people want it to be done. |
What about: https://github.com/cakephp/app/blob/3.next/webroot/index.php#L17-L26 // for built-in server
if (php_sapi_name() === 'cli-server') {
$_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
$url = parse_url(urldecode($_SERVER['REQUEST_URI']));
$file = __DIR__ . $url['path'];
if (strpos($url['path'], '..') === false && strpos($url['path'], '.') !== false && is_file($file)) {
return false;
}
}
|
Could but why?. Its only useful in the cli-server context, and having a middleware would mean it would be run on every request. |
Could we move all this code:
https://github.com/cakephp/app/blob/master/webroot/index.php#L17-L26
and this code:
https://github.com/cakephp/app/blob/master/webroot/index.php#L28-L37
... to bootstrap.php?
This would mean:
The text was updated successfully, but these errors were encountered: