Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127805 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 765181A00BC for ; Mon, 30 Jun 2025 15:33:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1751297478; bh=uMmdotIkt2lCQ6Fqjov7ZOvcPs4Zv79AWd0rU2mIdis=; h=References:In-Reply-To:Reply-To:From:Date:Subject:To:Cc:From; b=M7F0pGaFUnsLqbpCDflUHgMADevn6ZO5LQhWTxP8uHJeGnMcXzcMC0UtyhZh5vzIF YPJWGdZSdhOVSB02m3XbL5LKNDmLHsiywgta0cC27hWZAQK1foHSw4NUw8nVtl1Y0M WQVEXjWBc6RFHeAicCVMCYz3sWXezRWyCXR+sqDKyPAB7rBSR/7LDBlHvFX38+O1zv /grg+nz0SBYtzupBFO9fh25osshzcgkF7fRApkDNPVHoLjpwwdoAqr4vKd9FcrJ/aH OsUmfbm0qtfYjoQT95u84sGipA3uB1oojAqyzsHbRaU6+cHrA/8RIgHY9pGe4EY6WX Q2cXAMnl9u3xA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C2A5018004E for ; Mon, 30 Jun 2025 15:31:17 +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.2 required=5.0 tests=BAYES_20,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-f50.google.com (mail-io1-f50.google.com [209.85.166.50]) (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 15:31:17 +0000 (UTC) Received: by mail-io1-f50.google.com with SMTP id ca18e2360f4ac-86d00ae076dso186326539f.0 for ; Mon, 30 Jun 2025 08:33:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751297590; x=1751902390; 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=eq5neWl/WCypNhAf0wyGoz4l30rL2QKD6tX8Xel3TFc=; b=ObI8BJ2fiobTqsKJ6E02vqlVm6F4YhYJTx+utq0yfQ63Sp6exKhpDOgqm2L1G7zzeZ VpuK9qYidh3TBnpwYwR/jfSlx5Sn1eAaaPKFkrKA4fREXk19ZthPKPp93nz5onKwhNUF AefgsxDDKUvOvW0vt4hUtxOjqqlvVLzWBOMvR87LSe6zR34NkewI5o+WOYZI02D9Xox0 nA/525CtNk6PACw4n7VQ6j3D/Al/xnh1hXLVZfgp8B2gm43bWwFsitmqYajPexm9b5eb D9IuKLI4I6nvmyyA95q68Z7cjoLJGUJRPlgLoRhpH4RW8cT66SHWEmBxL4LAbDyKhTVD jGXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751297590; x=1751902390; 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=eq5neWl/WCypNhAf0wyGoz4l30rL2QKD6tX8Xel3TFc=; b=SUjfZONBBphBaA7lWZvOiBdZC+Sobgp9YjH5MNLx+aT6wSiCLkVl36HQJnFncQNgGF dsFm2KdiNouc1Epx5+6/DcGxQujsJfrgwdZLL5aH5WQ3+Cd/+9vmhUFeM33CI7M6Ub7e 43uGqDlzKe8otkW+eKA92Vg9oNwRkEhONugoB3lesSJErMgUWn7YbK+h178r6qzgi7uV HWN/D+KaqKpEH6RY1Fukqu1ozMKGVe1MoFKx68TBDwgMcGQA7SmFmcc99fE6CnbswCTK pmg659V8EhTKD9e6SkNil6pXzj07cVjZeY2Yj+hbPaOKnWubYGlYfdja01CM8nCC9404 YLrQ== X-Gm-Message-State: AOJu0Yxg74FMjs1H+O00l4/2NSONeS4ZL9WUrk8a+tfxAD21rtEhBOhe KefNtuZ9ZfPQiwpza3LTWUHCVE6dgBnRMX/FAAsJmxjsy76+fRdRgp1GbSEmVseI+iAI8e1hExB cpao4zB8OgVtMSMhTUXNRn8GfJmKB/zcMrkKd X-Gm-Gg: ASbGncujN03vDAHg0NEzuNSZ+tZ1yzmfu96jB1JaXox4KvHl9OmbLrCOTqF1EI5JSLr pipVJlg+fSJmar2fLCMuCONEMazy6so2a746EaJ2RcxzUc5PaTAHbZkEo45tQS9Ctb6o5FTYtSC dk676Z/7QKEOiGyUSLWUqpATe5CIJnhVaR9m+ZSdeMJ9OosDq2iLujqCON5cK1QY9aOwfLG7fx+ 028o4a64p81zDtF X-Google-Smtp-Source: AGHT+IEINhui/m/4W6iqoIST6CLbjIStIvwwdOb5JMyV0s/om2nbMnxIe8Xa5aJ7wi2trs6TGugFeHQwki1u6bVQUsY= X-Received: by 2002:a05:6e02:1a82:b0:3dd:f1bb:c75a with SMTP id e9e14a558f8ab-3df4b48d29amr137114315ab.8.1751297590227; Mon, 30 Jun 2025 08:33:10 -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: Reply-To: erictnorris@gmail.com Date: Mon, 30 Jun 2025 11:32:54 -0400 X-Gm-Features: Ac12FXx3HwD08xCGQU4OLWSkJJzMj6jP-Vf5g9o5kaFy7Ima-mDyi0yqDWPzsdA Message-ID: Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Object-oriented curl API v2 To: Ayesh Karunaratne Cc: PHP internals Content-Type: text/plain; charset="UTF-8" From: eric.t.norris@gmail.com (Eric Norris) Thanks for your response Ayesh! I hope to see this RFC on php.watch :) > However, I softly oppose this RFC in its current state and the way it > seems to be going. > > I have pushed Curl and libcurl to some uncommon cases such as HTTP/3, > DoH, the new debug callback (which I authored the PR for), IMAP, and a > few other obscure tweaks. For all of them, the current `curl_setopt` > worked, and the more I used it, the more I understood that having just > a few Curl functions and a sea of Curl options is the least > "presumptive way", regardless of the protocol and the options Curl > provides. > > The extension is named `Curl`, because it's supposed to provide Curl > functionality into PHP. It provides low-level functionality, but we > should leave it to the PHP users to build the libraries that have > fluent APIs. It would be helpful for me to understand what specifically you are objecting to in the current discussion, putting aside the suggested enumeration changes. Do you object to any HTTP-oriented methods at all, like something to set the HTTP method? Would you object to methods that apply to all, or nearly all, transport types, like a setTimeout() method? > I think a more light-weight approach would be to: > > - Move all of them to the `\Curl` namespace. > - Rename Curl options to `\Curl\Option` namespace, and rename them, > so that `CURLOPT_SSL_VERIFYHOST` becomes `Curl\Option\SSL_VERIFYHOST` > - Rename Curl error codes to similar `\Curl\Error` constants. > - Have the `CurlHandle` object accept options, e.g. > `$ch->setOption(Curl\Option\SSL_VERIFYHOST, 2)`. libcurl Easy handlers > do not have a way to retrieve the option once it's set, so there will > be no `getOption` either. > - Make Curl throw exceptions, and never `false` on `\Curl\execute()`, > with the Exception's error code and message mapped to the Curl error > code and message. We will not need to bring over `curl_error` or > `curl_errno` functions. Acknowledged, thank you. The RFC does propose what you're suggesting with never returning false and instead throwing exceptions, but it feels like it might still be useful to have properties on the actual object. Do you have opinions on that? > Realistically, I don't think we can deprecate and remove the `\curl_*` > functions any time soon, so this will actually add more maintenance > work for php-src at the end too. Agreed, I do not plan on suggesting this, not even under Future Scope.