Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127759 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 D15661A00BC for ; Thu, 26 Jun 2025 16:54:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1750956777; bh=GkiVZBSh0gUwdI649IpSQ0YOCajeGojfl8HgcW/Le9s=; h=Date:From:To:In-Reply-To:References:Subject:From; b=kBhFgEsDD38pAR23wlPVfQ6Cl32T1ded6SGpZuCfgggOxurd4jls8ACAOtcVg6h5E uFyjusFosMZ2wtNX3Pl01NFnFV9eo+0QAgRoJrwXeEx4hNBW4cAO4sHudV0iKRcvad 4ZmS78NQPZwLRgfA0NwH/eCwjE5BDXcOz0rLi6vRmk80Q9eZ9cGRVbN0FyEGaEIoDo 2eKqTcqyYVa5xy1Nv5DrEGtLinOUEpTD5WrbBximaZUjuW7ErRXq3/LckloOeINeI+ Zasn4GpQCSTegRAR+foZAMKt3REZpz6gKFkZKoObjLwAEVt9lN6xGWTcu8rARqXxkG 8Khp7eXVwPP2w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C3FEB18004E for ; Thu, 26 Jun 2025 16:52:55 +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=-2.8 required=5.0 tests=BAYES_00,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 fhigh-b5-smtp.messagingengine.com (fhigh-b5-smtp.messagingengine.com [202.12.124.156]) (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 ; Thu, 26 Jun 2025 16:52:55 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfhigh.stl.internal (Postfix) with ESMTP id 9B7F27A0165 for ; Thu, 26 Jun 2025 12:54:49 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-10.internal (MEProxy); Thu, 26 Jun 2025 12:54:49 -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=1750956889; x=1751043289; bh=PW5I4W9pcENoz6DpXbcC9 /AX9Awlnh1pVj0FlOoskdg=; b=Pk/xbG6E9nF6FWET2I0q7U4lj33zK7l0Gpn3l TsPq0d7Erq2RelvwpT2cDO+8n/wN9QU9DSWv7T2cxDNnG2Ofl1ys0eEkWihYR427 FOL9sI6wLlGggJ/iTIESmHNVgs5k4Qv71Aa6dvRDcXbGo5OpKotYnvXVf966kGkT BgD7ZcOBjQhNOOVeVNbzEoQEQ4swdt2lochuWxtp/O85I/AIkBkrEBM7MRrP89Rn b1c2GoseTGT79MnOILo7RJj6xaY7wK+WXDhuf1ROzlp/qsOo/IMycJIjmDoYKvZH EDshSlo1L0LUMNw+FBc6q5xNJw2WCOrP6Eq6f8cg6XLu0rvsw== 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=1750956889; x=1751043289; bh=P W5I4W9pcENoz6DpXbcC9/AX9Awlnh1pVj0FlOoskdg=; b=eWN3GhTHD1FtljOYn ETuZYOGeZo/uHUCoI9Yamzh4mlaGAs3A8rcUKHBsvZ3Ir3Y4cRUXVeAxSEgIOa2o +W/xJhye1tjumDPU6z4/xxxw1lYjlX56WD5QBImWfwGb0GvvFCkaovnn74mRbOS3 fHFqxWV5J4XX6rSkCKwfCo61fnAPfoHF28gBe1t5+flS9CARr1EFHJvLOVkmgFVB vfNCm0EYg53+2xgk1e0q6wZO6HYPmx8rvI7EF9LsYLyjx0MWajiMEl9i3pTGm2Cj ihOTyykSTJ45p774AxVIXW7XoRmI8fN763p7Mn7ZkaH9DDfmRKw1lVUewu2JZ25q 96igQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdejudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegrihhl ohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpe foggffhffvkfgjfhfutgfgsehtjeertdertddtnecuhfhrohhmpedfnfgrrhhrhicuifgr rhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomheqnecugg ftrfgrthhtvghrnhepkeelgfelgeelffdtudeiffeugedufeehtdehgeekvdfhveehhfeh kefgveegteegnecuffhomhgrihhnpehphhhprdhnvghtpdgvgigrmhhplhgvrdgtohhmne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhr hiesghgrrhhfihgvlhguthgvtghhrdgtohhmpdhnsggprhgtphhtthhopedupdhmohguvg epshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhp rdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 19023700063; Thu, 26 Jun 2025 12:54:49 -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: Thu, 26 Jun 2025 11:53:46 -0500 To: "php internals" Message-ID: <22a4327d-b27d-4e24-b07a-ae380fe8a0c4@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 Thu, Jun 26, 2025, at 11:25 AM, Eric Norris wrote: > Hello Internals, > > I'd like to formally propose a restart of the original object-oriented > curl API RFC (https://wiki.php.net/rfc/curl-oop): > > https://wiki.php.net/rfc/curl_oop_v2 > > The prior RFC seemed to get positive feedback, with a small consensus > around wanting enum(s) for curl options. I've taken that feedback and > incorporated it into a new RFC, as I am not the original author, but I > am interested in making another potential improvement to the curl > extension. > > In a nutshell, this version of the RFC: > > - uses enumerations for curl options and other curl constants > - introduces a new Curl namespace > > I have not yet created an implementation PR. I realize that is > somewhat discouraged, but I believe that this should be relatively > straightforward to implement (there's also the previous RFC's PR to > build on top of). The implementation of this RFC as it is now will > likely be tedious, however, so I'd like to get feedback on the > enumeration idea before committing to the work. > > I've outlined one open question in the RFC, which relates to the above: > > - Should we organize the curl option enumerations by value type? Or > have a single enumeration for all curl_setopt options and another for > all curl_multi_setopt options? > > If others (including the original RFC author) are interested in > working with me on this, I'm more than open to that, so please let me > know. > > Thanks, > Eric I still support this effort. 1. I don't think the Curl\Option namespace is necessary. They can just be in the main Curl namespace. 2. Please don't name the exception "Exception". It needs some slightly more useful name, to avoid confusion in a file that also uses \Exception. 3. I realize `Handle` is the name from the procedural API, but it's not very self-descriptive. Without knowing Curl, it's non-obvious that it's a self-executing request object. Is there a better name we could find while we're at it? 4. Love the use of aviz. :-) 5. Now here's the big one: Using enums rather than a bunch of constants is a good change. However, I feel like it doesn't go far enough. For instance, $ch = new Curl\Handle("https://example.com") ->setOptionInt(Curl\Option\IntOpt::ConnectTimeout, 30) ->setOptionBool(Curl\Option\BoolOpt::FollowLocation, true); Would be 10x easier to use were it: $ch = new Curl\Handle("https://example.com") ->setConnectionTimeout(30) ->setFollowLocation((true); Or for that matter, properties would now allow for those to even just be set directly on typed properties. (Though it wouldn't be chainable.) I realize that would be considerably more work to define all those methods (I don't even know how many Curl has, as I rarely use it directly). But it would result in a vastly easier to use API than "set some random integer-based field(EnumName, 30)". The latter is highly non-obvious. Especially when getting into POST requests with different body formats (something the RFC should include examples of), IMO, good ergonomics is more important than looking like the old, horribly obtuse API. As a worst case, perhaps the top-20 options or so could be converted to methods/properties, and the rest left to be ugly flags? --Larry Garfield