Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73768 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71090 invoked from network); 23 Apr 2014 22:30:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Apr 2014 22:30:05 -0000 Authentication-Results: pb1.pair.com header.from=park.framework@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=park.framework@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.83.46 as permitted sender) X-PHP-List-Original-Sender: park.framework@gmail.com X-Host-Fingerprint: 74.125.83.46 mail-ee0-f46.google.com Received: from [74.125.83.46] ([74.125.83.46:63652] helo=mail-ee0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D3/60-01676-BEE38535 for ; Wed, 23 Apr 2014 18:30:04 -0400 Received: by mail-ee0-f46.google.com with SMTP id t10so1230352eei.19 for ; Wed, 23 Apr 2014 15:30:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=PvCK0tcT7aafAibSc4MFoOHSAQyGXdYmB/YYKqkmhYI=; b=LWNkpyIkiDE4eXCrtNg4CGBAzWPiuV8a9KBbSjr3HgiRtUbYnHGojSbXsKXACip0hR CUGE1EbxqIx7A5MRvTAjdSKFPMybpb880PI4h8iLK0fC9lHlwlyPoj5enFUvM4r78nRZ OX2QCP3IS2bAr2hFnruJscjpPCGvUvc6IvsyejjmgCl0dkWCZhN0IaYtsJDSH0pZpiH3 WRU4lE6soUvcLQHZypf8L3k2HIpgD8oEXXLCWFauo3DZjk/3IYdrElG3wKYvB9wpIq4k 8LSycFMdNfAwLjjK7fQq3hNO5WyVf41rsgtjiTjBxW0yT9fvs6+qMGa5f5TjzfHRWqCI rysw== MIME-Version: 1.0 X-Received: by 10.14.246.1 with SMTP id p1mr65464381eer.20.1398292200398; Wed, 23 Apr 2014 15:30:00 -0700 (PDT) Received: by 10.14.107.199 with HTTP; Wed, 23 Apr 2014 15:30:00 -0700 (PDT) In-Reply-To: References: Date: Thu, 24 Apr 2014 01:30:00 +0300 Message-ID: To: Alexey Zakhlestin Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=001a1132f658e5a1ef04f7bd455f Subject: Re: [PHP-DEV] [FPM] Reused PHP script as daemon process From: park.framework@gmail.com (Park Framework) --001a1132f658e5a1ef04f7bd455f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: 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 : > > On 22 Apr 2014, at 02:27, Park Framework wrote= : > > > 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 =E2=80=8B=E2=80=8Brequest. > > Exposing FastCGI lib to userland is something we already were talking > about, but I don=E2=80=99t think your choice of API is good. > > Something like this would be much cleaner: > > $data =3D fastcgi_parse_request($input_stream_or_string); > > Then, you can call your handler manually, and: > > echo fastcgi_encode_response(200, ['hea' =3D> ['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 > > > > --001a1132f658e5a1ef04f7bd455f--