This partially reverts cec890c. In addition to other cleanup the commit changed
from using $_SERVER to getenv. As @kafene said on issue #21, getenv provides a
nicer API making the code clean. I.E.
$val = getenv('val') ?: 'default';
Instead of:
$val = isset($_SERVER['val']) ? $_SERVER['val'] : 'default';
Although this is true unfortuantly it is less reliable. Using getenv in this
way assumes the application is running under some sort of CGI interface or
an interface that is simulating the CGI interface.
While this assumption is very often true it is not always true. For example
when using [PHP built-in webserver][1] (useful for development) getenv will
return false for most of these values even through $_SERVER is populated. I
believe also some interfaces on Windows don't populate getenv.
This means that flight is not usable in those environments. By partially
reverting cec890c we re-enable flight in those environments.
For Engine.php and Response.php I just directly reverted cec890c. Since request
makes so much use of getenv it seemed wise to abstract the conditional checking
to keep the code clean via a private function.
The tests were also updated to populate $_SERVER instead of the environment
via putenv.
[1]: http://php.net/manual/en/features.commandline.webserver.php
Core functionality has been moved to a namespaced Engine class. The
existing Flight class is now just a static pass-through to the Engine class.
Also fixed autoloading and initialization issues.
See: http://php.net/manual/en/function.header.php
2nd option, $replace, should be false if sending multiple headers with the same name.
The difference can be observed by editing index.php (the example index page) so that before `echo 'hello'` is a line: `flight::response()->cache(false);`
and editing Response.php so that before `exit($this->body)` is a line: `var_dump(headers_list());`
Before change:
`array (size=3)`
`0 => string 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' (length=38)`
`1 => string 'Cache-Control: max-age=0' (length=24)`
`2 => string 'Pragma: no-cache' (length=16)`
After:
`array (size=5)`
`0 => string 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' (length=38)`
`1 => string 'Cache-Control: no-store, no-cache, must-revalidate' (length=50)`
`2 => string 'Cache-Control: post-check=0, pre-check=0' (length=40)`
`3 => string 'Cache-Control: max-age=0' (length=24)`
`4 => string 'Pragma: no-cache' (length=16)`