Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109168 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 35703 invoked from network); 20 Mar 2020 18:38:49 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 Mar 2020 18:38:49 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CAF691801FD for ; Fri, 20 Mar 2020 10:02:16 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 20 Mar 2020 10:02:16 -0700 (PDT) Received: by mail-qk1-f169.google.com with SMTP id p6so7619065qkm.0 for ; Fri, 20 Mar 2020 10:02:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=benramsey.com; s=google; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=8L0dJ8oozsz5LrBNK1UAYmJpVYchjfgSCr0jjmVJvW0=; b=e0Z7bQv+WlYxJ+RopIRgFyFouX9UEldR0XB5+yb+AcFfkPKaFFv5cf+i1pHdY7S4bl r3Ns9l/x+GRMaCYJbXXE8Mh1HAPVWtT9HhlDtuQ2iZrFgVMe1vNXemgax9R4trxeLxsx fmamwltDLwjfXd2nymiQ70FWiRb5hFPZyFUs7Y7PcLzha1WiF3/EIQu22B4oQvRrKjKO AyhpYWSuox31/XePZ47qeFuKWqHXA/YPlKmXbWH7YB25QIpsGdsY9wYTVn1YVJRrbUTm 96AYUP5RD7hSsM8jRix8TyC1XBr2WEW43sRHMJDyC/EXtiFcyDLIaczzYC73yBJCzE5l dHlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=8L0dJ8oozsz5LrBNK1UAYmJpVYchjfgSCr0jjmVJvW0=; b=uVhzyggL3Pu1+dV4CRtfYpfd6p39SQhiNm2pUJ4NDtDDQ+ENUMao/8B4+K+LKpgY9X fTC5s7Qxfo00Va7qD09jSBhea2nc54TQ9ZgkLcW6ylVOdFYA/Jxg7aV9jvA9rMrAxq53 xvHREetQMq59MernjF+PqTEfr1MiU0xh1aG3kp6PZDUTJrRZg3dNmSfsT3aJO24L/2hR kPxtv0GOZNg7CRz07XWN3sdkyHQ6yx7Zc4BTRooYm7n5yliFI09XndEOC1ClvdHNr6fo Y7qNvZ/bkhleRdZ5eSpPXcRxMQWb3lrI0AebBlzBa9JySY027vVOEzVV8PvcJOyX+kFh TUCQ== X-Gm-Message-State: ANhLgQ2jE3is0FnC0B0IOIq+AGAiqG/PbWnuKSvzOiezurbz8HGSC+ez HibBezRBSVYg3PdAujTV0lAMZ35cZ6N0cg== X-Google-Smtp-Source: ADFU+vuahmgC/AV6rhVG0MXkNvyDIhL4tbwAqCunhfPhS799vcOgh40WkX2I33cQAgRDYbZRt4S+gQ== X-Received: by 2002:a37:b44:: with SMTP id 65mr8173592qkl.201.1584723732274; Fri, 20 Mar 2020 10:02:12 -0700 (PDT) Received: from [10.10.42.56] (h96-61-170-50.lvrgtn.dsl.dynamic.tds.net. [96.61.170.50]) by smtp.gmail.com with ESMTPSA id u13sm4529414qku.92.2020.03.20.10.02.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Mar 2020 10:02:11 -0700 (PDT) Message-ID: <5AF2B693-53C8-432E-89DC-E707232DF42C@benramsey.com> Content-Type: multipart/signed; boundary="Apple-Mail=_234DF4A2-E590-481D-8460-461DF3C114E7"; protocol="application/pgp-signature"; micalg=pgp-sha256 Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.60.0.2.5\)) Date: Fri, 20 Mar 2020 12:02:10 -0500 In-Reply-To: <8B8A570A-545C-4CBF-9145-C9FC0B0E2AA1@pmjones.io> Cc: PHP Internals To: "Paul M. Jones" References: <8B8A570A-545C-4CBF-9145-C9FC0B0E2AA1@pmjones.io> X-Mailer: Apple Mail (2.3608.60.0.2.5) Subject: Re: [PHP-DEV] [VOTE] Server-Side Request and Response Objects (v2) From: ben@benramsey.com (Ben Ramsey) --Apple-Mail=_234DF4A2-E590-481D-8460-461DF3C114E7 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Mar 20, 2020, at 08:31, Paul M. Jones wrote: >=20 > Hi all, >=20 > I have opened the vote on Server-Side Request and Response Objects at = . >=20 > The voting period will close two weeks from today on Fri 03 Apr 2020. Paul, I apologize for not speaking up more on the list during the discussion phase. The one issue I did raise -- regarding the use of value objects instead of arrays -- hits at one of the reasons why I=E2=80=99m voting = =E2=80=9Cno=E2=80=9D on this proposal. Others raised similar concerns on the list, which is why it wasn=E2=80=99t necessary for me to jump in and restate the same = concerns. I appreciate the desire to keep this RFC small. Surely, it could grow astronomically into a huge library with tons of classes and interfaces, and being in core would be a detriment to it, since developers could not iterate as quickly and users could not upgrade as often. For this reason, I think this functionality is best provided by userland libraries for now. And now, a tangent=E2=80=A6 =46rom the RFC: > PHP has lacked core server-side request and response objects for > its entire existence PHP hasn=E2=80=99t had these objects in core because of the way the = SAPIs work. In fact, I think the objects could be confusing because of this. Python=E2=80=99s WSGI defines request and response objects for Python as = a way for the web application and the web server to communicate, while remaining implementation-agnostic. If PHP were to implement something of this sort, I think it should explicitly adopt PSR-7 and PSR-15 interfaces and a modified form of PEP-3333 (WSGI)[1] to work with the various SAPIs. In simplified terms, one could specify a callable that the SAPI would invoke, passing it a PSR-7 ServerRequestInterface object and PSR-15 RequestHandlerInterface object. It might look something like this: use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; function application( ServerRequestInterface $request, RequestHandlerInterface $handler ): ResponseInterface { // Do stuff... $response =3D $handler->handle($request); // Do more stuff... return $response; // SAPI handles response object. } // Tell the SAPI what callable to invoke. ini_set('sapi.handler', 'application'); This is already an approach that many PHP frameworks have adopted, and I think there is a lot of value in codifying this server communication at the core, while remaining light on the definition of the objects, and even allowing applications to provide and define their own implementations. As another pointed out, I think this will become more important as PHP gets stronger support for long-running processes. For now, I think this problem is best handled in userland. Cheers, Ben [1]: https://www.python.org/dev/peps/pep-3333/ --Apple-Mail=_234DF4A2-E590-481D-8460-461DF3C114E7 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iHUEAREIAB0WIQToXQMR3fpbrPOmEOewLZeYnIwHGwUCXnT3EgAKCRCwLZeYnIwH G+d3AP9HHW6i5bQ4WeqaX6MJIVQPmW3Bqdo3wvZOfpEwcW4qTgD/RkGRTgx1B22L 7BZawWmvJ0Nd1q4ghhaUUVagEvj3kG8= =QHx9 -----END PGP SIGNATURE----- --Apple-Mail=_234DF4A2-E590-481D-8460-461DF3C114E7--