Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113476 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 94810 invoked from network); 11 Mar 2021 15:49:59 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Mar 2021 15:49:59 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6D6141804B4 for ; Thu, 11 Mar 2021 07:42:28 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.5 required=5.0 tests=BAYES_20,BODY_8BITS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mercury.negativeion.net (mercury.negativeion.net [199.38.81.6]) by php-smtp4.php.net (Postfix) with ESMTP for ; Thu, 11 Mar 2021 07:42:27 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mercury.negativeion.net (Postfix) with ESMTP id 5A14220CC1677D for ; Thu, 11 Mar 2021 10:42:27 -0500 (EST) Received: from mercury.negativeion.net ([127.0.0.1]) by localhost (mercury.negativeion.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id a_zo2kwH7wsa for ; Thu, 11 Mar 2021 10:42:25 -0500 (EST) Received: from [10.0.1.101] (unknown [173.225.146.47]) by mercury.negativeion.net (Postfix) with ESMTPSA id 54DAE20CC1676C for ; Thu, 11 Mar 2021 10:42:25 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) X-Priority: 3 In-Reply-To: Date: Thu, 11 Mar 2021 09:42:24 -0600 Content-Transfer-Encoding: quoted-printable Message-ID: <0C1221DA-6EC6-410B-B6FD-5A18F33ADCD5@trowski.com> References: To: php internals X-Mailer: Apple Mail (2.3608.120.23.2.4) Subject: Re: [PHP-DEV] [VOTE] Fibers From: aaron@trowski.com (Aaron Piotrowski) > On Mar 11, 2021, at 7:56 AM, =E9=9F=A9=E5=A4=A9=E5=B3=B0 = wrote: >=20 > Hi, > I am come from Chinese, we may have some cultural differences, and = there may be some difficulties in communication. I try to express my = opinion. > To be precise, the fiber can only be used for amphp and reactphp or = other event-driven asynchronous IO frameworks developed using php. The = RFC does not mention how an extension uses fiber. > Fiber is not like threads or processes of operating system. It is not = parallel, nor is it concurrent. This requires an event-driven scheduler = to have practical value. Currently php does not have event-driven = support. So normal web developers don=E2=80=99t know how to use fiber. = It is for developers of asynchronous io programming.=20 > I just suggest first to provide a PECL extension like = ext-event/ext-libevent, no need to be integrated into php now. Swoole is = also provided to users as a PECL extension. >=20 Hello, I agree that this feature is targeted at libraries wishing to provide = better async I/O. What I disagree with is that this means it should not = be a part of PHP. Whether many developers realize it or not, several commonly used = libraries already contain some async I/O features, often implemented = with promises, which have some API trade-offs to attempt to integrate = async into typical synchronous code. Guzzle, Symfony, and Psalm are = three commonly used libraries that have asynchronous APIs available. Having fibers available in core will allow these libraries to offer = async code with an improved, more intuitive API as well as expand their = use of async I/O beyond what it typically has been used for, HTTP = requests, to include databases, redis, file access, etc. An event scheduler is needed for async I/O to work, but several = implementations already exist in user space and work very well with = fibers, as I and ReactPHP team can attest. Fibers are the key to = integrating these event schedulers into the greater PHP community. Swoole provides an entire large, opinionated framework for async coding. = That=E2=80=99s fantastic! However, it is not a flexible tool that any = library can use for a variety of purposes. It is more akin to choosing a = framework such as Laravel or Yii to write your PHP app. Event-driven programming is desperately needed in the PHP community. = Right now PHP contains nearly all the tools for fantastic, clear, = intuitive user space async code. This is the one missing piece. Aaron Piotrowski