Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122063 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 34388 invoked from network); 29 Dec 2023 22:56:00 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Dec 2023 22:56:00 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DA9FF180053 for ; Fri, 29 Dec 2023 14:56:26 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 29 Dec 2023 14:56:26 -0800 (PST) Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-33687627ad0so6664355f8f.2 for ; Fri, 29 Dec 2023 14:55:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703890557; x=1704495357; darn=lists.php.net; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=LnYCJZrFCIx6qArqB7o2+grBy6eGATH0QfT2ymk3yQw=; b=YtdOMU7KUYbtxd/JjnGjXSUNPWg6VZsaJRECJwpm4NChgKuWEsSes/SMdbntgoybtU b9l5uj40j+L/FcsV2Pu4d5s+FwaW+ik0j0rLuNKVkiEOMhvrWWpSrJ7HqIIYAQd8/Vcz oBWhD6Z0gCXxbxZoyQAvbPv/nUoxgswNV8dSFo072kMErooINZ9bEu0f6Px3Kr2qT57Q z3E0ksyHPzAr2mw52r68TeI/3KGBWOo0Dh/qRt2J/5uFXmC0zTRKVoGPDVwtmnw2kt6J 2VhwRAtjUFPLvpWgAvYndwrXFKeVBByf7EHMzDQpbokbJ7YQ3ZYINzWAU3u3HiHZkCis s1qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703890557; x=1704495357; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=LnYCJZrFCIx6qArqB7o2+grBy6eGATH0QfT2ymk3yQw=; b=mUJELP+0V8MjGQsS3MwsOcUiaFQEcEpVW2Upfed+0tPLBe8zWe/Tn5E0km8L1YdgW8 xyyBuiptJZ1e2ttmgxcZZIJXoBlerz0ZeJE7+Cg+7sHDQj5bX42rVO1K5dm7CiK9FRS6 DfDAsBttwMSFu52hY7WG/esNp891QbsSK+K46lITjEnfPlxWUhIEEj8u7/ZVet73+Mob qa2NQ+zqd+AX9QPZjImuYGf+i6SYmppAhL94N9dnFjOIvagYKolhnuZq4NlJP80exu5i xlTef7JwBJKf2uga/+N9cs9Bd1hEsToli5xvIQSLDy+C1UK5EGYFmbEJqIXzk9cDgvVN /FFg== X-Gm-Message-State: AOJu0Yxnj7+vJrw1G3G/3XNBYoYf9a7bDwW0uFn22N8lbkNnKKqjhO+o f6lQhG/71faDZqxbQgmBo1dg1k4/wV0= X-Google-Smtp-Source: AGHT+IG1VLyFwzRFZ8AEOlg1AueNH9vUOf5Mwtf1TWuZeTnKYkWPSHginQYLR9GYJTPUyhe6qL418w== X-Received: by 2002:a05:600c:4f53:b0:40d:5b84:b6d3 with SMTP id m19-20020a05600c4f5300b0040d5b84b6d3mr2676427wmq.89.1703890556951; Fri, 29 Dec 2023 14:55:56 -0800 (PST) Received: from [192.168.0.22] (cpc83311-brig21-2-0-cust191.3-3.cable.virginm.net. [86.20.40.192]) by smtp.googlemail.com with ESMTPSA id r20-20020a05600c459400b0040c3dcc36e6sm32158607wmo.47.2023.12.29.14.55.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Dec 2023 14:55:56 -0800 (PST) Content-Type: multipart/alternative; boundary="------------om8vrF75Ti1acK0TxzoU8dG7" Message-ID: <6f7815b9-80cc-4e08-819a-49dca090116f@gmail.com> Date: Fri, 29 Dec 2023 22:55:55 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-GB To: internals@lists.php.net, =?UTF-8?Q?K=C3=A9vin_Dunglas?= References: <5060b986-2e5a-46e4-9c83-763e5b155e83@gmail.com> In-Reply-To: Subject: Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs From: rowan.collins@gmail.com (Rowan Tommins) --------------om8vrF75Ti1acK0TxzoU8dG7 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 29/12/2023 21:14, Kévin Dunglas wrote: > On Fri, Dec 29, 2023 at 8:14 PM Rowan Tommins > wrote: > > - FrankenPHP expects the user to manage the main event loop ... > > > This isn't exact. FrankenPHP does manage the event loop (the Go > runtime manages it - through a channel - under the hood). Perhaps "event loop" was the wrong term; what I was highlighting is that to use FrankenPHP or RoadRunner, you have to write a while loop, which explicitly handles one request at a time. In Swoole, there is no such loop: you register event handlers and then call $server->run() once. Similarly, WSGI mandates that the server "invokes the application callable once for each request it receives from an HTTP client". It's a distinction of pull/poll (the application must actively block until next request) vs push/subscribe (the application is passively invoked whenever needed). > I already replied to Crell about that. It will totally possible to > expose more complex HTTP message objects in the future, > but PHP currently lacks such objects. The only things we have are > superglobals (which are more or less similar to CGI variables, as done > in WSGI) and streams. It's why we're using them. The use of objects vs arrays wasn't the main difference I was trying to highlight there, but rather the overall API of how information gets into and out of the application. FrankenPHP is the only server listed which needs to reset global state on each request, because the others (including Python WSGI and ASGI) use non-global variables for both input and output. I notice that the Laravel Octane adaptor for FrankenPHP takes that global state and immediately converts it into non-global variables for consumption by the application. > I'm not sure what you mean by "async PHP environment". OpenSwoole, AMPHP, ReactPHP, etc - servers which expose concurrency directly to the user of PHP. In those environments, global state isn't just reused between consecutive requests, it's shared between multiple requests running concurrently, so a global "current request" and "current response" have no meaning. > WebSockets and WebTransport are a different kind of beast, they are > much lower level than HTTP and will require a different API anyway > (and probably a lot of other adaptations in core) to be supported in PHP. WebSocket support in PHP is just as real as worker modes and asynchronous concurrency. Swoole has a WebSocket implementation included in core [https://openswoole.com/docs/modules/swoole-websocket-server] and Roadrunner has a plugin for it [https://roadrunner.dev/docs/plugins-centrifuge/current] In both cases (and in ASGI), the same basic API is used as with HTTP, but using a more general concept of "events" in place of "requests". Other PHP implementations include Ratchet [http://socketo.me/] and AMPHP Websocket Server [https://github.com/amphp/websocket-server]. Note that both async and WebSockets were mentioned as possible "forward compatibility". If we're talking about "next generation SAPIs", these are the kinds of features that people will be - and already are - developing; so it seems foolish not to at least consider them when designing new baseline APIs. Regards, -- Rowan Tommins [IMSoP] --------------om8vrF75Ti1acK0TxzoU8dG7--