Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122062 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 30301 invoked from network); 29 Dec 2023 21:14:47 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Dec 2023 21:14:47 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 438E1180051 for ; Fri, 29 Dec 2023 13:15:14 -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=-2.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,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-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (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 13:15:13 -0800 (PST) Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-7815ba075f9so193994185a.0 for ; Fri, 29 Dec 2023 13:14:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunglas-fr.20230601.gappssmtp.com; s=20230601; t=1703884485; x=1704489285; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=caVOFshrwRl+1u3awcrwmmFWfFHeg7QdGWc+mNBqXuY=; b=t9a39LR7ipd32/EpMfKdAhXr3ApJ9elDCRb1rzfvdvgNtfEYMaVqrAYBLekCbGrBVE Ova0Dvj7zZClAbW/r7aIlSCfLk7oY1Kp2K9KLCnl3jsADDF/TAAqwTf7HVpgZyjKTprl dG5bRcqZ0wo06HZVciYkjPzQA3j3uNmY8l4QxfM4SEb8wjsZc4Jb9A21JqodxLgmxWEK lqigYIk8u7y/YfaT9E2kebl4GO+V5AX8USO7wnatgdWJSozO9jGWvY403wRQmW7FL32I u6CGwGviYXvz+RiIF0e97d+KybjnWDh1p+hkGR9XuQYvnTnMzhceUcEmB4bL4rLJateE eBWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703884485; x=1704489285; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=caVOFshrwRl+1u3awcrwmmFWfFHeg7QdGWc+mNBqXuY=; b=SvuQ9lgNuJXZmTJ1JwUg9/8M5yiaylP9VzZDMzuLxcElNXFUTF4HNHY/5UZXAc4LwD yKjCbhIPNfBngImT94MRUXfvg8b6MckkrIofP1hTJWz/1/u3QUAZ+eYD0Jt8diQs8+Wo U+HX5aOgrnKWSeEOoU0jKwTCgQqckupnlWxFXYSDWn2LigFvI7dEiAFhsfIkoL89HCqy sd1fWBKtBYDLNe/eIaRvK9m+Sbvyq5uPOqpsklITUXJsmHByxSqSSCweF+lDr7MRp9Ff x6Gn7kZFL13Y43YyWeeHf+M8nOfeqGL52KTd5yHf6ZNmPUVyTE2U0zcvLMtc/4RjQwE+ zjAg== X-Gm-Message-State: AOJu0YwfuBdkGNhsxzDzYKVoPsnyxSrFoZdWPypWQ92zXKKz0HPMGo1i bt/2lNwFvpimhU72vsGI75BhbUR+KTJr92vgPgjN8fJZ0YmjyIeThw7e6FG3 X-Google-Smtp-Source: AGHT+IG62g8K2ydFNfvAxDp7+wEag75h+MhYrhtzij09L05IkeejDkfiCBZMNZ9gA3O0v3ZPE+wxtbqCfqJTO6gXY00= X-Received: by 2002:a05:6214:21e4:b0:67f:8d92:a3b5 with SMTP id p4-20020a05621421e400b0067f8d92a3b5mr16671651qvj.118.1703884485102; Fri, 29 Dec 2023 13:14:45 -0800 (PST) MIME-Version: 1.0 References: <5060b986-2e5a-46e4-9c83-763e5b155e83@gmail.com> In-Reply-To: <5060b986-2e5a-46e4-9c83-763e5b155e83@gmail.com> Date: Fri, 29 Dec 2023 22:14:34 +0100 Message-ID: To: Rowan Tommins Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000791f38060dac8508" Subject: Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs From: kevin@dunglas.fr (=?UTF-8?Q?K=C3=A9vin_Dunglas?=) --000000000000791f38060dac8508 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Dec 29, 2023 at 8:14=E2=80=AFPM Rowan Tommins wrote: > - FrankenPHP expects the user to manage the main event loop, repeatedly > passing the server a function to be called once; it doesn't pass > anything into or out of the userland handler, instead resetting global > state to mimic a non-worker environment > [https://frankenphp.dev/docs/worker/#custom-apps] > This isn't exact. FrankenPHP does manage the event loop (the Go runtime manages it - through a channel - under the hood). The frankenphp_handle_request() pauses the thread until the Go runtime gives back control to the C thread (when a request is dispatched to this worker). It's actually very similar to WSGI. As I explained in my previous messages, it's expected that other SAPIs handle the event loop too (using the primitives provided by the language they are written in). > - RoadRunner doesn't use a callback at all, instead providing methods to > await a request and provide a response; it directly uses PSR-7 and > PSR-17 objects [https://roadrunner.dev/docs/php-worker/current/en] > - OpenSwoole manages the main loop itself, and uses lifecycle events to > interface to userland code; the HTTP 'Request' event is passed custom > Request and Response objects > [https://openswoole.com/docs/modules/swoole-http-server-on-request] > 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. If PHP adds a higher-level API at some point, we'll be able to upgrade this part as every other part of the PHP code base. But it's an unrelated topic: having such higher-level representations of HTTP messages would be beneficial both in "normal" and in "worker" mode. > it would be adapted for an async PHP environment, or with WebSockets, > for instance. > I'm not sure what you mean by "async PHP environment". 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. In Go, for instance, the WebSocket and WebTransport APIs aren't the same as the HTTP API. Best regards, --000000000000791f38060dac8508--