From af2cd43dd4978d19dae241f5ec75bb719de22a63 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Wed, 12 Mar 2025 06:01:28 -0400 Subject: [PATCH 1/7] Fix dependabot error fecthing package manifest Error message: Error during file fetching; aborting: /package.json not found dependency_file_not_found --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5db0ad09b..eb9cfb523 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -20,7 +20,7 @@ updates: - "github_actions" - package-ecosystem: "npm" - directory: "/" + directory: "/www/scripts/" schedule: interval: "daily" commit-message: From 9bd62516c22c5644527562dbbac4273bf8410e3f Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Wed, 12 Mar 2025 06:21:48 -0400 Subject: [PATCH 2/7] Add badge for dependabot status --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 78d47a8ab..f415d7c2a 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![](https://img.shields.io/github/license/php-curl-class/php-curl-class.svg?style=for-the-badge)](https://github.com/php-curl-class/php-curl-class/blob/master/LICENSE) [![](https://img.shields.io/github/actions/workflow/status/php-curl-class/php-curl-class/ci.yml?style=for-the-badge&label=build&branch=master)](https://github.com/php-curl-class/php-curl-class/actions/workflows/ci.yml) [![](https://img.shields.io/github/actions/workflow/status/php-curl-class/php-curl-class/release.yml?style=for-the-badge&label=release&branch=master)](https://github.com/php-curl-class/php-curl-class/releases/) +[![](https://img.shields.io/github/actions/workflow/status/php-curl-class/php-curl-class/dependabot/dependabot-updates?style=for-the-badge&label=Dependabot&branch=master)](https://github.com/php-curl-class/php-curl-class/actions/workflows/dependabot/dependabot-updates) [![](https://img.shields.io/packagist/dt/php-curl-class/php-curl-class.svg?style=for-the-badge)](https://github.com/php-curl-class/php-curl-class/releases/) PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs. From 99c97ea0e52d3fcd382ea75a01e16e7d3d672c31 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 16 Mar 2025 16:57:27 -0400 Subject: [PATCH 3/7] =?UTF-8?q?=E2=AC=86=20Bump=20tj-actions/changed-files?= =?UTF-8?q?=20from=2045=20to=2046=20(#935)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [tj-actions/changed-files](https://github.com/tj-actions/changed-files) from 45 to 46. - [Release notes](https://github.com/tj-actions/changed-files/releases) - [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md) - [Commits](https://github.com/tj-actions/changed-files/compare/v45...v46) --- updated-dependencies: - dependency-name: tj-actions/changed-files dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cf77ee245..be5ad59b5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,7 +14,7 @@ jobs: - name: Get changed python files id: changed-files - uses: tj-actions/changed-files@v45 + uses: tj-actions/changed-files@v46 with: files: "**/*.py" From e2960d912b664678fde4021425d7358b55dd0c79 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 22 Mar 2025 15:05:40 -0400 Subject: [PATCH 4/7] =?UTF-8?q?=E2=AC=86=20Update=20prismjs=20requirement?= =?UTF-8?q?=20from=20^1.29.0=20to=20^1.30.0=20in=20/www/scripts=20(#934)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updates the requirements on [prismjs](https://github.com/PrismJS/prism) to permit the latest version. - [Release notes](https://github.com/PrismJS/prism/releases) - [Changelog](https://github.com/PrismJS/prism/blob/master/CHANGELOG.md) - [Commits](https://github.com/PrismJS/prism/compare/v1.29.0...v1.30.0) --- updated-dependencies: - dependency-name: prismjs dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Zach Borboa --- www/scripts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/scripts/package.json b/www/scripts/package.json index 20a3e1293..43c0c0963 100644 --- a/www/scripts/package.json +++ b/www/scripts/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "prismjs": "^1.29.0" + "prismjs": "^1.30.0" } } From 45a7b1b671b927fbe88937b8d0d7a6573e3ea166 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Sun, 23 Mar 2025 05:00:39 -0400 Subject: [PATCH 5/7] Add methods like Curl::setGet() for each HTTP request method (#936) * Adding methods like Curl::setGet() for each HTTP request method Adding these methods to separate the request initialization from the execution. Methods added: Curl::setDelete() Curl::setGet() Curl::setHead() Curl::setOptions() Curl::setPatch() Curl::setPost() Curl::setPut() Curl::setSearch() * Fix loading local test servers Error message: +++ declare -A pids run_phpunit.sh: line 77: declare: -A: invalid option declare: usage: declare [-afFirtx] [-p] [name[=value] ...] Error message: +++ server_count=7 +++ pids=() run_phpunit.sh: line 85: "7" - 1: syntax error: operand expected (error token is ""7" - 1") * Clean up --- examples/multi_curl_add_curl.php | 8 +--- examples/multi_curl_add_curl_low_level.php | 33 +++++++++++++ src/Curl/Curl.php | 56 ++++++++++++++++++---- tests/run_phpunit.sh | 6 +-- 4 files changed, 86 insertions(+), 17 deletions(-) create mode 100644 examples/multi_curl_add_curl_low_level.php diff --git a/examples/multi_curl_add_curl.php b/examples/multi_curl_add_curl.php index f932205a3..be5b809c3 100644 --- a/examples/multi_curl_add_curl.php +++ b/examples/multi_curl_add_curl.php @@ -11,23 +11,19 @@ }); $curl_1 = new Curl(); -$curl_1->setOpt(CURLOPT_POST, true); -$curl_1->setOpt(CURLOPT_POSTFIELDS, [ +$curl_1->setPost('https://httpbin.org/post', [ 'to' => 'alice', 'subject' => 'hi', 'body' => 'hi Alice', ]); -$curl_1->setUrl('https://httpbin.org/post'); $multi_curl->addCurl($curl_1); $curl_2 = new Curl(); -$curl_2->setOpt(CURLOPT_POST, true); -$curl_2->setOpt(CURLOPT_POSTFIELDS, [ +$curl_2->setPost('https://httpbin.org/post', [ 'to' => 'bob', 'subject' => 'hi', 'body' => 'hi Bob', ]); -$curl_2->setUrl('https://httpbin.org/post'); $multi_curl->addCurl($curl_2); $multi_curl->start(); diff --git a/examples/multi_curl_add_curl_low_level.php b/examples/multi_curl_add_curl_low_level.php new file mode 100644 index 000000000..f932205a3 --- /dev/null +++ b/examples/multi_curl_add_curl_low_level.php @@ -0,0 +1,33 @@ +complete(function ($instance) { + echo 'call to "' . $instance->url . '" completed.' . "\n"; +}); + +$curl_1 = new Curl(); +$curl_1->setOpt(CURLOPT_POST, true); +$curl_1->setOpt(CURLOPT_POSTFIELDS, [ + 'to' => 'alice', + 'subject' => 'hi', + 'body' => 'hi Alice', +]); +$curl_1->setUrl('https://httpbin.org/post'); +$multi_curl->addCurl($curl_1); + +$curl_2 = new Curl(); +$curl_2->setOpt(CURLOPT_POST, true); +$curl_2->setOpt(CURLOPT_POSTFIELDS, [ + 'to' => 'bob', + 'subject' => 'hi', + 'body' => 'hi Bob', +]); +$curl_2->setUrl('https://httpbin.org/post'); +$multi_curl->addCurl($curl_2); + +$multi_curl->start(); diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index 6027cd618..a9a95e272 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -275,6 +275,12 @@ private function progressInternal($callback) * @return mixed Returns the value provided by exec. */ public function delete($url, $query_parameters = [], $data = []) + { + $this->setDelete($url, $query_parameters, $data); + return $this->exec(); + } + + public function setDelete($url, $query_parameters = [], $data = []) { if (is_array($url)) { $data = $query_parameters; @@ -295,7 +301,6 @@ public function delete($url, $query_parameters = [], $data = []) if (!empty($data)) { $this->setOpt(CURLOPT_POSTFIELDS, $this->buildPostData($data)); } - return $this->exec(); } /** @@ -605,6 +610,12 @@ public function execDone() * @return mixed Returns the value provided by exec. */ public function get($url, $data = []) + { + $this->setGet($url, $data); + return $this->exec(); + } + + public function setGet($url, $data = []) { if (is_array($url)) { $data = $url; @@ -613,7 +624,6 @@ public function get($url, $data = []) $this->setUrl($url, $data); $this->setOptInternal(CURLOPT_CUSTOMREQUEST, 'GET'); $this->setOptInternal(CURLOPT_HTTPGET, true); - return $this->exec(); } /** @@ -642,6 +652,12 @@ public function getInfo($opt = null) * @return mixed Returns the value provided by exec. */ public function head($url, $data = []) + { + $this->setHead($url, $data); + return $this->exec(); + } + + public function setHead($url, $data = []) { if (is_array($url)) { $data = $url; @@ -650,7 +666,6 @@ public function head($url, $data = []) $this->setUrl($url, $data); $this->setOpt(CURLOPT_CUSTOMREQUEST, 'HEAD'); $this->setOpt(CURLOPT_NOBODY, true); - return $this->exec(); } /** @@ -661,6 +676,12 @@ public function head($url, $data = []) * @return mixed Returns the value provided by exec. */ public function options($url, $data = []) + { + $this->setOptions($url, $data); + return $this->exec(); + } + + public function setOptions($url, $data = []) { if (is_array($url)) { $data = $url; @@ -668,7 +689,6 @@ public function options($url, $data = []) } $this->setUrl($url, $data); $this->setOpt(CURLOPT_CUSTOMREQUEST, 'OPTIONS'); - return $this->exec(); } /** @@ -679,6 +699,12 @@ public function options($url, $data = []) * @return mixed Returns the value provided by exec. */ public function patch($url, $data = []) + { + $this->setPatch($url, $data); + return $this->exec(); + } + + public function setPatch($url, $data = []) { if (is_array($url)) { $data = $url; @@ -692,7 +718,6 @@ public function patch($url, $data = []) $this->setUrl($url); $this->setOpt(CURLOPT_CUSTOMREQUEST, 'PATCH'); $this->setOpt(CURLOPT_POSTFIELDS, $this->buildPostData($data)); - return $this->exec(); } /** @@ -722,6 +747,12 @@ public function patch($url, $data = []) * [3] http://php.net/ChangeLog-5.php#5.5.11 */ public function post($url, $data = '', $follow_303_with_post = false) + { + $this->setPost($url, $data, $follow_303_with_post); + return $this->exec(); + } + + public function setPost($url, $data = '', $follow_303_with_post = false) { if (is_array($url)) { $follow_303_with_post = (bool)$data; @@ -746,7 +777,6 @@ public function post($url, $data = '', $follow_303_with_post = false) $this->setOpt(CURLOPT_POST, true); $this->setOpt(CURLOPT_POSTFIELDS, $this->buildPostData($data)); - return $this->exec(); } /** @@ -757,6 +787,12 @@ public function post($url, $data = '', $follow_303_with_post = false) * @return mixed Returns the value provided by exec. */ public function put($url, $data = []) + { + $this->setPut($url, $data); + return $this->exec(); + } + + public function setPut($url, $data = []) { if (is_array($url)) { $data = $url; @@ -773,7 +809,6 @@ public function put($url, $data = []) if (!empty($put_data)) { $this->setOpt(CURLOPT_POSTFIELDS, $put_data); } - return $this->exec(); } /** @@ -784,6 +819,12 @@ public function put($url, $data = []) * @return mixed Returns the value provided by exec. */ public function search($url, $data = []) + { + $this->setSearch($url, $data); + return $this->exec(); + } + + public function setSearch($url, $data = []) { if (is_array($url)) { $data = $url; @@ -800,7 +841,6 @@ public function search($url, $data = []) if (!empty($put_data)) { $this->setOpt(CURLOPT_POSTFIELDS, $put_data); } - return $this->exec(); } /** diff --git a/tests/run_phpunit.sh b/tests/run_phpunit.sh index 40060d73f..46d1e1c03 100755 --- a/tests/run_phpunit.sh +++ b/tests/run_phpunit.sh @@ -74,13 +74,13 @@ export PHP_CURL_CLASS_TEST_MODE_ENABLED="yes" # Start test servers. Run servers on different ports to allow simultaneous # requests without blocking. server_count=7 -declare -A pids -for i in $(seq 0 $(("${server_count}" - 1))); do +pids=() +for i in $(seq 0 "$(echo "${server_count} - 1" | bc)"); do port=8000 (( port += $i )) php -S "127.0.0.1:${port}" server.php &> /dev/null & - pids["${i}"]="${!}" + pids+=("${!}") done # Determine which phpunit to use. From d57b0049a97661e2d0e65d330f0a5d59c03c3c96 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Sun, 23 Mar 2025 09:01:35 +0000 Subject: [PATCH 6/7] Update readme --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index f415d7c2a..c5b8c66a2 100644 --- a/README.md +++ b/README.md @@ -200,6 +200,7 @@ More examples are available under [/examples](https://github.com/php-curl-class/ Curl::__construct($base_url = null, $options = []) Curl::__destruct() Curl::__get($name) +Curl::__isset($name) Curl::afterSend($callback) Curl::attemptRetry() Curl::beforeSend($callback) @@ -279,10 +280,13 @@ Curl::setDefaultJsonDecoder() Curl::setDefaultTimeout() Curl::setDefaultUserAgent() Curl::setDefaultXmlDecoder() +Curl::setDelete($url, $query_parameters = [], $data = []) Curl::setDigestAuthentication($username, $password = '') Curl::setFile($file) Curl::setFollowLocation($follow_location = true) Curl::setForbidReuse($forbid_reuse = true) +Curl::setGet($url, $data = []) +Curl::setHead($url, $data = []) Curl::setHeader($key, $value) Curl::setHeaders($headers) Curl::setInterface($interface) @@ -290,18 +294,23 @@ Curl::setJsonDecoder($mixed) Curl::setMaxFilesize($bytes) Curl::setMaximumRedirects($maximum_redirects) Curl::setOpt($option, $value) +Curl::setOptions($url, $data = []) Curl::setOpts($options) +Curl::setPatch($url, $data = []) Curl::setPort($port) +Curl::setPost($url, $data = '', $follow_303_with_post = false) Curl::setProtocols($protocols) Curl::setProxy($proxy, $port = null, $username = null, $password = null) Curl::setProxyAuth($auth) Curl::setProxyTunnel($tunnel = true) Curl::setProxyType($type) +Curl::setPut($url, $data = []) Curl::setRange($range) Curl::setRedirectProtocols($redirect_protocols) Curl::setReferer($referer) Curl::setReferrer($referrer) Curl::setRetry($mixed) +Curl::setSearch($url, $data = []) Curl::setStop($callback = null) Curl::setTimeout($seconds) Curl::setUrl($url, $mixed_data = '') From 062f58613524947451efdb3dd7d7217719670a9f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 24 Mar 2025 18:04:25 +0000 Subject: [PATCH 7/7] =?UTF-8?q?Bump=20version:=2011.0.5=20=E2=86=92=2011.1?= =?UTF-8?q?.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ src/Curl/Curl.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f52432310..16d4118d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ backwards-incompatible changes that will affect existing usage. +## 11.1.0 - 2025-03-24 + +- Add methods like Curl::setGet() for each HTTP request method ([#936](https://github.com/php-curl-class/php-curl-class/pull/936)) + ## 11.0.5 - 2025-03-11 - Fix PHPStan static analysis errors ([#929](https://github.com/php-curl-class/php-curl-class/pull/929)) diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index a9a95e272..d429ab1d2 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -6,7 +6,7 @@ class Curl extends BaseCurl { - public const VERSION = '11.0.5'; + public const VERSION = '11.1.0'; public const DEFAULT_TIMEOUT = 30; public $curl = null;