What is CLI Server?
2 answers
Since version 5.4.0, the PHP command line interpreter (CLI) also acts as an embedded web server .
command line parameters required to run the CLI as a web server:
-S <addr>:<port> Run with built-in web server.
-t <docroot> Specify document root <docroot> for built-in web server.
The feature getallheaders()
apparently was not implemented on the embedded web server from the beginning, it was added in version 5.5.7
+4
source to share
With php bug # 66606 , built-in web server php header stores the value Content-Type
and Content-Length
in HTTP_CONTENT_TYPE
and HTTP_CONTENT_LENGTH
.
You can get these values ββdepending on the PHP_SAPI value:
if ('cli-server' === PHP_SAPI) {
if (array_key_exists('HTTP_CONTENT_LENGTH', $_SERVER)) {
$content_length = $_SERVER['HTTP_CONTENT_LENGTH'];
}
if (array_key_exists('HTTP_CONTENT_TYPE', $_SERVER)) {
$contentType = $_SERVER['HTTP_CONTENT_TYPE'];
}
}
0
source to share