Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122430 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 qa.php.net (Postfix) with ESMTPS id D1C6D1ACEBF for ; Sun, 18 Feb 2024 15:27:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1708270029; bh=m8ZAzm3jz1KgoAC2OfXt80UTnfVn0b7QK7GcNsupWQ0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=DQPVWzH57iNenxThLA4/z5A5hannTq74op5A3aSncK4byqvhidmZKiaZNsrf7c7nE v9oo5mk+9DPDSnvwVIBCYOGkthheKDjtVPeIEIkubmezhz0Ym/aWB5Jc/kmsZSUcDn ml3LAwmULOboC/V9YcbS3cF/CwJaNjuVOQSM9YqNHDpMuWYEmbf1k93cpEP6+W+Q4Z sfKvw3MWhyVmL8NUbbB7c7uHSAm6wWMoDZ2FN1T2rOOfRGTt9Piq7mfJnaRByktlBo 49iCRrRkvlHMDO9GSh/QspnS0YI9028YPuf1bLnYNiF7+iE9kRUjWnz3d180pyuIXM qHesgVsv4rusg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 862E01804F5 for ; Sun, 18 Feb 2024 15:27:08 +0000 (UTC) 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.1 required=5.0 tests=BAYES_00,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,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (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 ; Sun, 18 Feb 2024 07:27:08 -0800 (PST) Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-563c595f968so3821127a12.0 for ; Sun, 18 Feb 2024 07:27:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708270024; x=1708874824; 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=iibYFD9QP4WSiUDllVObx99uy5k6PnuoEU4NRqjiCW8=; b=QiWuQcs5SQXwjEEHwL9W/YlM0mNyJsTXkFqGsqSX9TwLViqrWVeCLCzZTIHvvNUmOH asRFTRUvD87LqQNwWd+ByvrUueON6eQSuWRx65frx5YKXVE+df3n7xqL4yc7FUAEwMcA DoOeoTETr37AoYPhK2EY/WyOF608Tz6xYvUKj/Hh1MuL04nQgsTOMTf69hgcxh1lqrTF Rdgvk5Ng4S4shaID35IlpAczPCGhLX5ix5X1bpd3TckstCjQY28Q7t4mvAR/Np8oz9dz InmtMND7Y4jt+RV9pnPq/prae3YF0SGxnimoyF2Zl0tqW/RdlAQ0H+0laHfwO0jR45mV 69iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708270024; x=1708874824; 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=iibYFD9QP4WSiUDllVObx99uy5k6PnuoEU4NRqjiCW8=; b=H/f1KK9B+1axxkgC784RbzXEEewMNuFRXW+L6aW9Zzz2rv6WDtlj4PYB8rhIXmWFdj y/8X7DZ3H1s2YZJnHMXiRaQm06XfOVVemLU63AGxHWGE/X2YlNqpOkqnz3Jnzjk7blj9 kyBBjX15vWcqSDMC6SkErpsNzkeccFlUYYv24lGOe3c7FPPe9nVTf5n3l1PK4rwGuiAi OEMLizpmBrwGsSUA/A6Qc1feJdb6nerehoY5X5NPoyDP+7es4LiB89C5+W+rtr1KZBQp Em4UiDIoo/RFso6aDyi4/xIEQ7YA/0vMeK2OorVGXAbt7kZj2RpW2z0MsDy3h7TiroGC Yaiw== X-Gm-Message-State: AOJu0YyfjIlf+5teanuXEFVWVxwG4cOrWh0XKNpNNI9UVYzZwgGq/sgh SG5TJ3iGUXfvCaelxpIpZ4eOE1fYceZTp4PJONeWMw23PsVAKn6uM6lbsSi7sGS+NlGaeXafaIT iR6I31enqrpyrpkXrZ/pR1wpcGpJbCvU5 X-Google-Smtp-Source: AGHT+IFKxZf//aegcmyyhlMpAQU8MQuewHYj9+hOAwrT/cXEf6vD3rttyThe+KQ1HvMMwy0pfHzZnRM0vmK11jjdSyU= X-Received: by 2002:aa7:d156:0:b0:564:7087:e40 with SMTP id r22-20020aa7d156000000b0056470870e40mr453296edo.18.1708270023588; Sun, 18 Feb 2024 07:27:03 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <9bc2d842-5f56-4062-8b21-3b41310f2c86@app.fastmail.com> In-Reply-To: Date: Sun, 18 Feb 2024 16:26:37 +0100 Message-ID: Subject: Re: [PHP-DEV] Re: [RFC] OOP API for cURL extension To: Rowan Tommins Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000efbdab0611a99b23" From: kjarli@gmail.com (Lynn) --000000000000efbdab0611a99b23 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Feb 18, 2024 at 12:41=E2=80=AFPM Rowan Tommins wrote: > On 17 February 2024 15:57:20 GMT, Larry Garfield > wrote: > > >The RFC would also benefit greatly from some practical examples of using > the new API. Right now it's not clear to me (as someone who almost never > uses Curl directly) how/why I'd use any of these, since there's still "a > whole crapton of int constants I don't understand floating around." The > suggestion to use an Enum (or several) here is a good one and would help = a > lot with that, so I'm +1 there. > > To my mind, the *eventual* aim should be that users don't *need* a > userland wrapper just to make a simple request in a readable way, and tha= t > setting raw curl options becomes an advanced feature that most users neve= r > need. > > I know a lot of people's minds will immediately go to request and respons= e > objects, but I think we can go a long way by just making well-named metho= ds > wrapping one or two curl options each, so that you could write this: > > $ch =3D new CurlHandle('https://example.com'); > $ch->setMethod('POST'); > $ch->setRequestBody('{"stuff":"here"}'); > $ch->setBasicAuth('admin', 'correct-horse-battery-staple'); > $result =3D $ch->executeAndReturn(); > > Note that I am not saying every one of those methods needs to be added > right now; adding a few at a time may be sensible to have time to discuss > good names and signatures. But to me, renaming CURLOPT_POSTFIELDS to > Curl\StringOptionsEnum::POSTFIELDS doesn't get us very far - users > shouldn't need a raw curl setting for such a basic feature in the first > place. > > Regards, > > -- > Rowan Tommins > [IMSoP] > Having a lot of setters for options might make it really hard to find the methods you're looking for in terms of auto-complete in your IDE. Would it make sense to split options into a separate object (or perhaps multiple), that could in theory also be shared between different CurlHandle instances? --000000000000efbdab0611a99b23 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Sun, Feb 18, 2024 at 12:41=E2=80= =AFPM Rowan Tommins <rowan.co= llins@gmail.com> wrote:
On 17 February 2024 15:57:20 GMT, Larry Garfield <larry@garfieldtech.com= > wrote:

>The RFC would also benefit greatly from some practical examples of usin= g the new API.=C2=A0 Right now it's not clear to me (as someone who alm= ost never uses Curl directly) how/why I'd use any of these, since there= 's still "a whole crapton of int constants I don't understand = floating around."=C2=A0 The suggestion to use an Enum (or several) her= e is a good one and would help a lot with that, so I'm +1 there.

To my mind, the *eventual* aim should be that users don't *need* a user= land wrapper just to make a simple request in a readable way, and that sett= ing raw curl options becomes an advanced feature that most users never need= .

I know a lot of people's minds will immediately go to request and respo= nse objects, but I think we can go a long way by just making well-named met= hods wrapping one or two curl options each, so that you could write this:
$ch =3D new CurlHandle('https://example.com');
$ch->setMethod('POST');
$ch->setRequestBody('{"stuff":"here"}');
$ch->setBasicAuth('admin', 'correct-horse-battery-staple'= ;);
$result =3D $ch->executeAndReturn();

Note that I am not saying every one of those methods needs to be added righ= t now; adding a few at a time may be sensible to have time to discuss good = names and signatures. But to me, renaming CURLOPT_POSTFIELDS to Curl\String= OptionsEnum::POSTFIELDS doesn't get us very far - users shouldn't n= eed a raw curl setting for such a basic feature in the first place.

Regards,

--
Rowan Tommins
[IMSoP]

=C2=A0Having a lot of setters f= or options might make it really hard to find the methods you're looking= for in terms of auto-complete in your IDE. Would it make sense to split op= tions into a separate object (or perhaps multiple), that could in theory al= so be shared between different CurlHandle instances?
--000000000000efbdab0611a99b23--