Add, function fastcgi_handle_request(callable $name) for reused script as
daemon process.
With each new request, all superglobals variables ($_GET, $POST, $_COOKIE,
$_SERVER, ...) with new values from current request.
Sample:
<?php
ob_start()
;
set_time_limit(0);
function run()
{
//... payload
fastcgi_finish_request();
}
fastcgi_handle_request('run');
?>
If you implement this functionality for PHP will be new opportunities and
performance optimization via runtime cache.
2014-04-22 0:27 GMT+02:00 Park Framework park.framework@gmail.com:
Add, function fastcgi_handle_request(callable $name) for reused script as
daemon process.With each new request, all superglobals variables ($_GET, $POST, $_COOKIE,
$_SERVER, ...) with new values from current request.Sample:
<?php
ob_start()
;
set_time_limit(0);function run()
{//... payload
fastcgi_finish_request();
}fastcgi_handle_request('run');
?>
If you implement this functionality for PHP will be new opportunities and
performance optimization via runtime cache.
Actually that looks like fastcgi_handle_request() will block the process,
which means, that this one fasctgi-process cannot get used for other
scripts anymore.
Add, function fastcgi_handle_request(callable $name) for reused script as
daemon process.With each new request, all superglobals variables ($_GET, $POST, $_COOKIE,
$_SERVER, ...) with new values from current request.
Exposing FastCGI lib to userland is something we already were talking about, but I don’t think your choice of API is good.
Something like this would be much cleaner:
$data = fastcgi_parse_request($input_stream_or_string);
Then, you can call your handler manually, and:
echo fastcgi_encode_response(200, ['hea' => ['de', 'rs']], $body);
lower-level functions could be useful too (for partial answers, etc.)
--
Alexey Zakhlestin
CTO at Grids.by/you
https://github.com/indeyets
PGP key: http://indeyets.ru/alexey.zakhlestin.pgp.asc
I simplified the example, it is possible to discuss in detail the API
There are two options, a high-level API abstraction from SAPI or low tier
API which depends on the SAPI
Abstract API
spl_server_loop(callable $name)
The infinite receiving new requests and run custom callable.
PHP send response to the client automatically, all the user response
headers and body (ob_get_contents()).
After each iteration makes ob_clean()
.
Sample:
<?php
$callable = function()
{
MyFrameWork::run();
}
// This code execute once
MyFrameWork::init($config);
//...
// This infinite receiving new requests and run custom callable
spl_server_loop($callable);
?>
Historically that PHP developers are abstracted from SAPI.
Continue the practice for daemon process script.
Or use SAPI
fastcgi_handle_request(callable $name)
fastcgi_parse_request($input_stream_or_string);
fastcgi_encode_response($code, $headers, $body);
But then your code will run on only one SAPI, such work as Apache module,
this code can not.
The meaning of this API to allow the user complete control processes
without the possibility of transfer to other SAPI
2014-04-22 14:12 GMT+03:00 Alexey Zakhlestin indeyets@gmail.com:
Add, function fastcgi_handle_request(callable $name) for reused script as
daemon process.With each new request, all superglobals variables ($_GET, $POST,
$_COOKIE,
$_SERVER, ...) with new values from current request.Exposing FastCGI lib to userland is something we already were talking
about, but I don’t think your choice of API is good.Something like this would be much cleaner:
$data = fastcgi_parse_request($input_stream_or_string);
Then, you can call your handler manually, and:
echo fastcgi_encode_response(200, ['hea' => ['de', 'rs']], $body);
lower-level functions could be useful too (for partial answers, etc.)
--
Alexey Zakhlestin
CTO at Grids.by/you
https://github.com/indeyets
PGP key: http://indeyets.ru/alexey.zakhlestin.pgp.asc