Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127790 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 4A7131A00BC for ; Mon, 30 Jun 2025 07:06:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1751267095; bh=R2eD2FaSTew7OCmRDtMu1Rf/GXIsv7PjLg9MnBToSEg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=RW7Ed9WGuJkWedXdQP3jXx9L27HZxnFvzGGVPCNZdBX8tjMi722dB5yM3QF9c95ve fbPbz4UQvUNVp4bR7t9E/x2cum/q8WSlpzUBhL/GdCkilPRbbHv02hNO9XQ/n/HgK8 Iewx3huuGLSoEKg9Xq3v/8Dj8ZAZOTq7jzX5v6XkNown8E6k2nGO+m2GjgBAqCn446 IAJtIiOB+WyxqkFSFpOZy3FxAvd9yXYYkK+ny1UR4zOIi11OBS/60LtxdNoQAms/Vb CGRUjGE11Xh2Ec8J/orFXjbfD3C0RFcG7FeGEzWFevHD1jXPOAwLESytV9XOkdSaT7 O5IXj243cbXEg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 54FE118004E for ; Mon, 30 Jun 2025 07:04:54 +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=-0.4 required=5.0 tests=BAYES_50,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.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 ; Mon, 30 Jun 2025 07:04:51 +0000 (UTC) Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3a536ecbf6fso2275996f8f.2 for ; Mon, 30 Jun 2025 00:06:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751267203; x=1751872003; 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=YGfhzDtxfoI6LkE04YjjtdAq3hwT3UbUIUL0RCxAD3w=; b=T102PDkaxMvlDCHWQ6LDA26ptSdJLnrCLEW1/1KgEgUt0tJbEGb28q7WYHdzLAgSCk Ng78ccMDOx90KoM4ql2CDPTpS1X08zWNY5UGNLmVhkb1zO+r8YMRk2EcYsdSX71nVMnd GDq1ZEYlntvBIw/dsZdFd5VD1Doyg2ca5uBRL4UVvrWZslQ2xMrvC8l2rExssXbw5li2 pl4/UvEnotGYen/+XCw6TKXNJFVtG40M1H18Yzy7dyLwkZqQqaPJd8P21WwdO8JYrDBd HePCAAzT6C7KAaqRxFoAtehXNrwgi6lq5ft3PyLvOfMiN5ajEdmRLwuKdY3jDRYyIUUA OAgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751267203; x=1751872003; 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=YGfhzDtxfoI6LkE04YjjtdAq3hwT3UbUIUL0RCxAD3w=; b=n/r75lzW+MTOA8xY4CbSbXR7yZePIliUzpub8nnBMReM3bNV02DL1zOx9Y+Y1cNYI2 JAJeobKNojpsWe+L9LsAx3p+kzUUdda2JmWNZWvEHVryeUMrHBIFrQjYE2OZHyJ00sFI eQo+oDLJjw+dnmGSlbn7rMJs7OAJWW0x8IN+2g4zigrIpv8yFYQBqmDXXQFwB+0qrcKS oCPQiWoLon2EYECniDTfETCpLX/4g1rf+v5Wnxvh5XLymnqHIbKYija+KOgX1+cGUd+q gRuvrWLIXfkYV7iW/CNVUf1vbQ3Cd9qJwhaasbt3QDKYnO4QMPi6EbPXDMSXJ91zJfo3 p8vA== X-Gm-Message-State: AOJu0YwuOTvRTwRn0+LyjQTjjpKYieKOQ731wbZuIMbGw4s9j01CO8tK cwcr11h6Wpb7sqZmofIMla25lpb3YMB5aeY0JNo4Es5gneZfPcWENK9/8FOrGUYZ8lKmE+RSQD4 XtgKwWOrHKHQAr0UGtS1IUuXeVDVjByr8afJdpQI= X-Gm-Gg: ASbGnct26MPb5071nAg9cfT0GzV537laX52lsf8Cy5EFeMru7bOsGXpgGOIFBXpq8Ab SFo18A2IfVFvkIomuvfVAbWLr7oi8pDNrRNon3+cOajtgLz6f5u7Wq7SN2IJA2MO1hmfTKlpi/r TezrFTHKbU/jpmBJFlvxlLFM4LrEhYuPHoLovkG/RiJp10 X-Google-Smtp-Source: AGHT+IEPVnxJyLWlJhA8YQGs7FKyNYZOaQ71YFFFFKPJVbmxx/whM25KPY6QiZvfLTR/TXn1i2XQnbOn4I6lzU86GhQ= X-Received: by 2002:a05:6000:2d09:b0:3a5:5298:ce28 with SMTP id ffacd0b85a97d-3a8fdb2a72fmr7540988f8f.4.1751267203303; Mon, 30 Jun 2025 00:06:43 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 30 Jun 2025 10:06:06 +0300 X-Gm-Features: Ac12FXxKG_BbKiOxTYGR88ikyg2zwuYzf7nNVJlBOTrDfweu75aLYDzbK6srUaM Message-ID: Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Object-oriented curl API v2 To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000008f50950638c4ab7c" From: arvids.godjuks@gmail.com (Arvids Godjuks) --0000000000008f50950638c4ab7c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, 28 Jun 2025 at 08:03, Larry Garfield wrote= : > On Fri, Jun 27, 2025, at 4:58 PM, Ayesh Karunaratne wrote: > > > However, I softly oppose this RFC in its current state and the way it > > seems to be going. > > So I think we've identified a key disagreement about not just the goal, > but the intent. To what extent should PHP core ship with a usable HTTP > client? > > Right now it ships with Curl, which... in its current form is not usable. > It's a low-level tool with an inscrutable API we inherited from C. It's > not viable as a user-facing tool. It's a tool that's only useful to peop= le > writing client libraries like Guzzle or CurlClass or Symfony HTTP or such= . > > On the one hand, Marco is correct that for a web-centric language to not > ship with a non-sucky way to send web requests is... kinda embarrassing. > Even if the use cases where you can't install a 3rd party library are few= , > they are non-zero. And that also doesn't help new users figure out what = to > use. (Eg, the person who wrote most of the code for our main application > at work, learning PHP as he went, is sending lots of requests using... an > ungodly mess of curl that can't even understand. Because he didn't know > that things like Guzzle even existed.) > > On the other hand, Ben is correct that an HTTP client is a not-small task= , > with a very deep rabbit hole. > > So there's two closely related but distinct asks here: > > 1. Make working with curl suck less (giving it an OOP interface is part o= f > that but not all) > 2. Ship a useful first-party HTTP client that can handle the 80% case, > even if it's not full featured. > > Beefing up Curl's interface until it fulfills part 2 is one approach, but > not the only. > > At one extreme would be the "do nothing, status quo is fine" position. > Ayesh seems to be close to that position, maybe with a little polish for > funsies. The other extreme would essentially be "Guzzle in core," which = I > don't think anyone is advocating. Where between those extremes we should > land is debatable. > > Personally I'm of the mind that a simple, basic-features HTTP client in > core would be a good thing; that's central enough that it should not be > left to userland. It doesn't need to offer every possible feature; no ne= ed > for async multiplexing, for example. But sending GET and POST requests > with straightforward bodies should be table-stakes for a web language, an= d > right now, that's a second class citizen. If it's written in such a way > that it can be extended easily in user-space, so much the better. > > Whether that basic-features client is Curl itself or a bundled wrapper > that uses Curl, I have no strong preference. The challenge of making it > separate from Curl is, shocker, that it's bikeshed bait. Does that imply > using the new URL/URI classes? Does it imply we need request/response > objects? The rabbit hole indeed gets deep fast. > > So the first question, I think, is what is the consensus between these > three coarse-grained positions: > > 1. Status quo is fine. PHP core not having a user-friendly way to send > HTTP requests is acceptable. Maybe make Curl a little nicer, but only to > make life easier for Guzzle et al. > 2. We should develop the Curl API until it's usable for basic HTTP > behavior, but no further. > 3. We should bundle an HTTP client that wraps Curl (with or without minor > improvements to Curl), exact scope TBD. > > Personally, I'm open to either 2 or 3. 3 is more bikesheddable, but > possibly the better end result. > > Where does everyone else stand? > > --Larry Garfield > I think #2 is the way to go. I personally just use Symfony's HTTP Client 99.9% of the time - there is one exception in recent years where I had to go low-level cURL and craft an extremely specific HTTP request. Yes, it is a SOAP service for a government system, because of course it is. I'm not even sure it's a good idea to add those namespaced options: using > CURLOPT_SSL_VERIFYHOST is perfect to find the corresponding curl > documentation with your favorite search engine. php's doc is awesome, but > it cannot compete with the details provided by curl's doc on the topic. Valid. This cannot be avoided if any kind of RFC is to be accepted, so I think the next best solution is to put effort into documentation and ensure that things are referenced (like the new Enum options having very obvious links to the original constants and to the curl documentation), making discoverability easy. The good thing is that OOP API is purely new, so there is not going to be tons of old content about it to make things messy. --=20 Arv=C4=ABds Godjuks +371 26 851 664 arvids.godjuks@gmail.com Telegram: @psihius https://t.me/psihius --0000000000008f50950638c4ab7c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sat, 28 Jun 2025 at 08:03, Larry Garfi= eld <larry@garfieldtech.com> wrote:
On Fri, Jun 27, 2025, at 4:58 PM,= Ayesh Karunaratne wrote:

> However, I softly oppose this RFC in its current state and the way it<= br> > seems to be going.

So I think we've identified a key disagreement about not just the goal,= but the intent.=C2=A0 To what extent should PHP core ship with a usable HT= TP client?

Right now it ships with Curl, which... in its current form is not usable.= =C2=A0 It's a low-level tool with an inscrutable API we inherited from = C.=C2=A0 It's not viable as a user-facing tool.=C2=A0 It's a tool t= hat's only useful to people writing client libraries like Guzzle or Cur= lClass or Symfony HTTP or such.

On the one hand, Marco is correct that for a web-centric language to not sh= ip with a non-sucky way to send web requests is... kinda embarrassing.=C2= =A0 Even if the use cases where you can't install a 3rd party library a= re few, they are non-zero.=C2=A0 And that also doesn't help new users f= igure out what to use.=C2=A0 (Eg, the person who wrote most of the code for= our main application at work, learning PHP as he went, is sending lots of = requests using... an ungodly mess of curl that can't even understand.= =C2=A0 Because he didn't know that things like Guzzle even existed.)
On the other hand, Ben is correct that an HTTP client is a not-small task, = with a very deep rabbit hole.

So there's two closely related but distinct asks here:

1. Make working with curl suck less (giving it an OOP interface is part of = that but not all)
2. Ship a useful first-party HTTP client that can handle the 80% case, even= if it's not full featured.

Beefing up Curl's interface until it fulfills part 2 is one approach, b= ut not the only.

At one extreme would be the "do nothing, status quo is fine" posi= tion.=C2=A0 Ayesh seems to be close to that position, maybe with a little p= olish for funsies.=C2=A0 The other extreme would essentially be "Guzzl= e in core," which I don't think anyone is advocating.=C2=A0 Where = between those extremes we should land is debatable.

Personally I'm of the mind that a simple, basic-features HTTP client in= core would be a good thing; that's central enough that it should not b= e left to userland.=C2=A0 It doesn't need to offer every possible featu= re; no need for async multiplexing, for example.=C2=A0 But sending GET and = POST requests with straightforward bodies should be table-stakes for a web = language, and right now, that's a second class citizen.=C2=A0 If it'= ;s written in such a way that it can be extended easily in user-space, so m= uch the better.

Whether that basic-features client is Curl itself or a bundled wrapper that= uses Curl, I have no strong preference.=C2=A0 The challenge of making it s= eparate from Curl is, shocker, that it's bikeshed bait.=C2=A0 Does that= imply using the new URL/URI classes?=C2=A0 Does it imply we need request/r= esponse objects?=C2=A0 The rabbit hole indeed gets deep fast.

So the first question, I think, is what is the consensus between these thre= e coarse-grained positions:

1. Status quo is fine. PHP core not having a user-friendly way to send HTTP= requests is acceptable. Maybe make Curl a little nicer, but only to make l= ife easier for Guzzle et al.
2. We should develop the Curl API until it's usable for basic HTTP beha= vior, but no further.
3. We should bundle an HTTP client that wraps Curl (with or without minor i= mprovements to Curl), exact scope TBD.

Personally, I'm open to either 2 or 3.=C2=A0 3 is more bikesheddable, b= ut possibly the better end result.

Where does everyone else stand?

--Larry Garfield


=C2=A0I'm not even sure it's= a good idea to add those namespaced options: using CURLOPT_SSL_VERIFYHOST = is perfect to find the corresponding curl documentation with your favorite = search engine. php's doc is awesome, but it cannot compete with the det= ails provided by curl's doc on the topic.

Valid. This cannot be avoided if any kind of RFC is to be accepted, so I= think the next best solution is to put effort into documentation and ensur= e that things are referenced (like the new Enum options having very obvious= links to the original constants and to the curl documentation), making dis= coverability easy.
--
--0000000000008f50950638c4ab7c--