Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127767 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 79F801A00BC for ; Fri, 27 Jun 2025 03:51:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1750996174; bh=50e0uXqq5CbSrUafeFbznFEj8z4i33WVSeV6OxdnPSc=; h=References:In-Reply-To:Reply-To:From:Date:Subject:To:Cc:From; b=gZO/fUsmW++sqLLsmgQB2j3qzQuqX4etg4Ilwnb4NiswFvhToVbTJ/qvpbPMi3G+p Q0u4l3O+n0X5ZX42VruC3CjcnjgAzkgms5hrltvgqwISYvJzaKYp1eBBP63YFZy3xk B8iCXZLNgJza+STf7KPr/p+PPGrNCIbQBgME7seFPkorRftEPDXXCk8nyT5eUAnwkK WlKiWA0Jl9na3iP9czILiXrq3pRT+eNx1ySyPWVlXAlF6zlPevGIObwK+jAc5nk7Fz f0kFOgJ3VckKd5hxKcE3O/tzmfWyTyR9V7c4kt6LTjs5oMsekThMYxJhMdDBJlIm5g 0EWerkIDWNNfw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B8B8B18004D for ; Fri, 27 Jun 2025 03:49:33 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, FREEMAIL_REPLYTO,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-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) (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 ; Fri, 27 Jun 2025 03:49:33 +0000 (UTC) Received: by mail-io1-f51.google.com with SMTP id ca18e2360f4ac-86cf3dd8c97so133216039f.2 for ; Thu, 26 Jun 2025 20:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750996288; x=1751601088; darn=lists.php.net; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=50e0uXqq5CbSrUafeFbznFEj8z4i33WVSeV6OxdnPSc=; b=dgrkdjh2+XU4YmdmdY8Fs90PDqCwCfh0bkDG1XRsOR8svolZUUKuhITxqw+BctvWxm m8jE/1gppGJJGYd1OdDTLz5e1aOrbVJ5Nh09fEZ9orXrxDa3CKRk1EDuuhxG3ZlCoUqM ZLxoJQt2RgL06wAo62XAe6uEp6ClbrWk3/MZGnfm74MQUGWA6FqD4ClhY4sCHeD5aNNH fpC/T1ihpY5fi/6n1/Cy/mt2YoS96WkS2rNoF52KmyFc8Do+vh8VReYpnVQQGndPKsN8 k41sxZEr4GyP6W5UYMsb7Ws8V6Vxs8Km3r1nEH+bNOxQsiOEtTIRDGsyS0aXObwjlMp0 7S9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750996288; x=1751601088; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=50e0uXqq5CbSrUafeFbznFEj8z4i33WVSeV6OxdnPSc=; b=HXZUKA7JN9oG3GltpofTg+A8QwkwFrnqQ1K75IcbiiIPAIgvFS5/RSpAfhz3GcCT1U wuUFiGehp30Cwg2Ne8bWtALrbLMhdI+MVPuxuBHXIUOy7k4l81lt+KE6UlknIqlY3Tsv 75OGTfI2C0Iep8/7YQ7flJkv8wYfRLyBeNUNOGZTi7/Mcl0TBbDW4F9aIt2N7wiJc5jT 9u+n6JD6Tmm4jFB2qlfFeLfAMs/7uBsoIBvWAnEpgyd8jeICvjp/hXkdnRk+OtzE7G7e uzVZb4MAV+4HNytNwnJmMIqezeX/Ok0yDa8hA3M+yUi+/w5DNgVV1DryC7jAUuQ7botk tWKw== X-Gm-Message-State: AOJu0YxYZovWuox4/kN5sXfs+TSNjqWyEpOTPf8RMPPVCbzTGGjhwUcg V37qFPAm5+SnU1A/pvffVr5V2c+kJPJlVuaG+NMsucrNdG8YmFyfrHOVN+iXvhQOQOJibk6/bi/ /7lW4iqZ2uMet9dx9D1Ved1nmqmDS/dG8ZRik X-Gm-Gg: ASbGncs571+HF+Q6CE0exzNY2aDoXfFu4Uh4W03t2+10Hju35sjZ5P+AWxedT4C/b9P 88CIhrKUkSBZ7arzAwsm6QRYO1ry/CBkPX8VRrTii4vPKktUprwlaD4T3BT9+LTZ8pNAYYBHpi+ XX5KYJ+F7E2dHGO0vagmdj91xP0poOSY9wKnMKe3GCOxtbkiXAgSYQjj+7T8wBlPyjh8/27UQRT b0VyQ== X-Google-Smtp-Source: AGHT+IGzBc08yVPGC22pukJRh6Cvm/iuYqM0FD7mJLtzEed8HOkBJFS4vxiEtq1wSH7iMsER2zJIppRIXivkUr7DVfM= X-Received: by 2002:a05:6e02:3090:b0:3dc:88ca:5ebd with SMTP id e9e14a558f8ab-3df4abb854dmr27120745ab.20.1750996287713; Thu, 26 Jun 2025 20:51:27 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <22a4327d-b27d-4e24-b07a-ae380fe8a0c4@app.fastmail.com> In-Reply-To: Reply-To: erictnorris@gmail.com Date: Thu, 26 Jun 2025 23:51:11 -0400 X-Gm-Features: Ac12FXybk9KgqhgEjQjvLvHOT6fwdR25H2_cdWqJ0b522yNt5Morf_46YT4bV8c Message-ID: Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Object-oriented curl API v2 To: "Rowan Tommins [IMSoP]" Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" From: eric.t.norris@gmail.com (Eric Norris) Thanks Rowan! > I think calling it a "vision for a high-level API" is making it sound > far more grandiose than what I suggested. What I suggested, and would > still like to see, is a small number of additional methods, for setting > really common options in a more user-friendly way. I apologize for misrepresenting your suggestion. I was mainly responding to your "the eventual aim should be that users don't need a userland wrapper" comment, which I worry sounds closer to what Ben was (I believe) objecting to - a higher-level wrapper. Upon re-reading though, I think that's potentially an unfair take - you did go on to say "...just to make a simple request in a readable way". > Looking at my earlier message, my finger-in-the-air number was even > smaller than Larry's - a set of 10 methods, each covering a handful of > overlapping or closely related options. > > A single "setHttpMethod" method would bring immediate value, instead of > choosing between CURLOPT_HTTPGET, CURLOPT_POST, CURLOPT_PUT, > CURLOPT_NOBODY (for HEAD) and CURLOPT_CUSTOMREQUEST. > > Adding more helpers in later versions is entirely trivial, but we could > set the precedent with a first batch on day one. I'm not opposed to this, but I am - as previously stated - nervous about how and where we draw this line, since I expect there may be a lot of opinions here. That said, if the general consensus is that we want direct methods or properties for the N most common use-cases, I'm happy to make that change to the RFC. I can try to take a look at the curl options and do some github searches to see if I can identify common patterns. I agree that setting the HTTP method and timeout are good contenders. If someone else wants to propose a list as well, feel free! > The only other "high-level" API I see discussed in the previous thread > is splitting the execute() method, for exactly the same reason as > splitting setOpt(): type safety. > > public function executeAndReturn(): string > public function executeAndOutput(): void > public function executeToFile(Stream $fileHandle): void > public function executeWithCallback(callable $wrIteFunction): void > > The CURLOPT_RETURNTRANSFER, CURLOPT_FILE, and CURLOPT_WRITEFUNCTION > would then not exist in the option enum(s), because there would be no > way to make use of them. > > Unlike the helper methods, that's one we have to decide in advance - it > would be a mess to have those *as well as* a universal "execute(): ?string". If we were to go this route, I would suggest: public function fetch(): string public function execute(resource|callable $out): void that is, one method to just return the contents of the URL, and another to either write output to a file (including STDOUT, if the user desires), or to send output to a write callback.