Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127839 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 4DA061A00BC for ; Wed, 2 Jul 2025 16:08:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1751472368; bh=01S5GRZ5RgRyvI6gi5GqHM/9C5yp2ZLAlIZosIaNXNk=; h=Date:From:To:In-Reply-To:References:Subject:From; b=kfHlStjp5wv53pS/GgnzCtF5smNnwkypbqa1Il1ZqXbPkGy3KcLmDGey98nK+e4xI BLFPR/q6YfoicbgAy7BIHySOimF3K1agtfP+uBq1GAmUvQUkk8e3Hctu7NYNFFhR/w 4Erw38R7WbvtjDPtatr/rk2T6TW7U1ZRe5BAi0rj5KgMLNLYTkC3KzI3JNsO2v9dJO iPnUhMAxppYYreXS/YP++wEWdG4K0XFpXg2wB7OoitAAfAoUd1eHYD1KyZAbJiex4A NKzkgo1LfpPOYZKPoNmyfnhMNbUMk0mmdV9/dkL2ZjXb/ecWRumi5qVOJvLeMtyofc z4Sm2ES3XToqw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 56D82180054 for ; Wed, 2 Jul 2025 16:06:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fout-a8-smtp.messagingengine.com (fout-a8-smtp.messagingengine.com [103.168.172.151]) (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 ; Wed, 2 Jul 2025 16:06:07 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfout.phl.internal (Postfix) with ESMTP id F1E2CEC0445 for ; Wed, 2 Jul 2025 12:07:58 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-10.internal (MEProxy); Wed, 02 Jul 2025 12:07:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm2; t=1751472478; x=1751558878; bh=9FsJMObLtPv3RyoqsjVab ep5OFLkLjAhgMYBwfMJlrY=; b=lSEhXk9mniNgXRqmuN93/OicLNysnChhrc8/1 2qHgPkoh8ezAhxS5eYmEB+Q+/QHbRiVYZuReZNliFVMB/1lFgHscTjsnfLyjQxfA PtASvElHbPHM7GcPFoaFxPviowrFhha/yFky8ZtsYG3s4qliIfK0N4jE0n1LQNqg NoWV+dkIMZa2xCOfBeWXCeyR3zDdtbYoJJ7VtelBO5lzZGYlitiHYhH1D+hOQMMR Qsf67K46TBxCAKcEdxzfLLUnTsHcOY+UL+Dn2MDu4hunQerfNmFt+KDOjx8WzqC2 tTB19qpYEJ8d8QsqSDMYFE3JkCoDRZhTpynRiFCIlP6Tek3YA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1751472478; x=1751558878; bh=9 FsJMObLtPv3RyoqsjVabep5OFLkLjAhgMYBwfMJlrY=; b=VqH7aEsJRt/P+9TXn e3jkfxImADY7m27GZPmWZx5zSo3UjDaO8v2DX96sKVvGMoWET2CvA4p1lf7TLu/H xa9wQ3owB4XxY0cyb5rXaNVjAkfLO1APwrVHbeyiyzFAqj0UqxnlBfWscvhQXXiO zbyhkuMVDjchmuHcKB7E490P6oEJew2UhtRsn781lyOblyD5iYEeUhKwVPGBdXll 1EBHIKSnDhhn3Sd3B/pEa4/DSF6SPabXT9ugtzekHtS1YnpO7TDltV68kskLJjQg c68NVr7pidfXIU8yMHDxupuxn+46qtO8jueqXEDYHIoh6C22KzfNSnjk2k7y7Z46 ayYVQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddujeekfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefoggffhffvkfgjfhfutgfgsehtjeertdertddtnecuhfhrohhmpedfnfgrrhhrhicu ifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomheqne cuggftrfgrthhtvghrnhepudegvdelgfeugeehfeejteffudevleethfefgeejffffleeg tddtveekgeekudfgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmpdhnsggprhgtphht thhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhsse hlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 89C06700069; Wed, 2 Jul 2025 12:07:58 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: T6541924c602fb011 Date: Wed, 02 Jul 2025 11:06:53 -0500 To: "php internals" Message-ID: <544f5bea-bda9-438c-9355-68ee1aedd9ac@app.fastmail.com> In-Reply-To: References: Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Object-oriented curl API v2 Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Wed, Jul 2, 2025, at 10:48 AM, Eric Norris wrote: >> Based on the feedback so far (I do plan on waiting for more responses >> to your email), and on my own preferences, I wonder if there is a >> hybrid option I could propose. Perhaps the RFC could offer both a >> \Curl\Handle (tentative name) to address position 1, and a >> \Curl\BasicHttpHandle (also tentative name) that addresses position 2? >> If people were amenable, I'd even make the BasicHttpHandle a separate >> vote. >> >> I agree that 3 is both more bikesheddable and also possibly ideal, but >> I feel my above suggestion maybe strikes the right balance between the >> "status quo is fine, I don't want to see random HTTP-related methods >> on my low(est)-level curl object" and the "I'd like to do basic HTTP >> stuff with curl, without a library" crowds. >> >> Barring that, my preference would be 2, but I'd accept 1 just to have >> it pass - like I mentioned elsewhere, I think there is value in >> introducing namespaces and object-oriented APIs for "modernization" >> and language consistency reasons. > > Having thought about this some more, while I'm still feeling somewhat > positive about my suggestion I'm just not sure it's the best way to > proceed. I started to sketch what a BasicHttpHandle class would look > like, and I'm stuck on how to get data about the response out of the > class. > > Naively, we could have $response_status_code and $response_headers > properties, and have the same fetch() and execute() methods I > suggested elsewhere to get the response body. Alternatively, we could > return a simple CurlHttpResponse object which contains all three > properties in the fetch() and execute() implementations for the > BasicHttpHandle class. > > Both of these are fine, but they would lock us out of being PSR7 > compatible. I think that people would probably desire PSR7 > compatibility, and I would feel uncomfortable with eliminating or > tainting the possibility of achieving this. For example, if we had > this BasicHttpHandle and then later introduced PSR7 response objects, > we'd need to either break backwards compatibility for the class, or > introduce a second class. We could also go straight to returning a > PSR7 compatible response for the BasicHttpHandle class, but I think > that likely deserves its own RFC. > > So in closing, if people felt generally okay with the limitation of > not being PSR7 compatible, I'd probably still add some form of my > BasicHttpHandle suggestion as a secondary vote. If people thought PSR7 > was necessary, I'd drop it, and leave a PSR7-in-core RFC for the > future. In that case, I'd go with Larry's option 1 for the RFC; I've > currently updated the RFC to match that option for now. The question of PHP-native request/response objects has come up a couple of times, and even had an RFC that went to a vote (declined). My stance has been, and remains, that such objects do NOT need to match PSR-7... but they should be powerful enough to effectively replace/displace PSR-7. If it's just another backend that PSR-7 consumes, we've added very little to the ecosystem. If they're robust enough that they can replace PSR-7 and HttpFoundation in time, we've helped to standardize the ecosystem. (And FIG will be able to adapt, don't worry.) (Eg, I would strongly recommend leveraging properties instead of methods for any built-in objects, which didn't exist when PSR-7 was written but now so; we should absolutely use the new built-in URI/URL classes instead of user-space ones, etc.) Of course, as you can expect, "design and include request/response objects powerful enough to supplant PSR-7" is a non-small and highly bikesheddable topic, and PHP is notoriously structurally bad at being able to have those conversations. That's part of why it's never happened. --Larry Garfield