Simple HTTP cURL client for PHP 7.1+ based on PSR-18

Overview

Simple HTTP cURL client for PHP 7.1+ based on PSR-18

Build Status Code Coverage Scrutinizer Code Quality Total Downloads Latest Stable Version License


Installation

composer require sunrise/http-client-curl

QuickStart

composer require sunrise/http-factory
use Sunrise\Http\Client\Curl\Client;
use Sunrise\Http\Factory\RequestFactory;
use Sunrise\Http\Factory\ResponseFactory;

$client = new Client(new ResponseFactory());
$request = (new RequestFactory)->createRequest('GET', 'http://php.net/');
$response = $client->sendRequest($request);

echo $response->getStatusCode(), PHP_EOL;

cURL options

https://www.php.net/manual/ru/curl.constants.php

$client = new Client(new ResponseFactory(), [
    \CURLOPT_AUTOREFERER => true,
    \CURLOPT_FOLLOWLOCATION => true,
]);

Parallel execution of multiple requests

$requests = [
    (new RequestFactory)->createRequest('GET', 'http://php.net/'),
    (new RequestFactory)->createRequest('GET', 'http://php.net/'),
];

$client = new Client(new ResponseFactory());
$responses = $client->sendRequests(...$request);

foreach ($responses as $i => $response) {
    // note that you can get the response's request by its index...
    echo sprintf('%s => %d', $requests[$i]->getUri(), $response->getStatusCode()), PHP_EOL;
}

Test run

composer test

Useful links

Comments
  • Implement set/get curl options methods

    Implement set/get curl options methods

    Changed log

    • It's related to issue #2.
    • Implement the set and get curl options to avoid overriding the protected $curlOptions variable.
    • Using the ?? syntax to check whether the specific CURL options are existed on Client::padCurlOptions method.
    opened by peter279k 6
  • Implement set/get curl options

    Implement set/get curl options

    As title, I think we should implement the set and get methods to manipulate the protected $curlOptions.

    To prevent overriding the existed curl options for the array $curlOptions argument in Client class constructor, it should check whether the options are set currently.

    And the overriding option work is on Client::padCurlOptions method.

    enhancement 
    opened by peter279k 3
  • provide psr/http-client-implementation version 1.0

    provide psr/http-client-implementation version 1.0

    Closes #12

    The doubt about providing "^1.0" or "1.0" make me read a lot about composer and packagist virtual packages and found that there are no defined rules for provides section related to version constraints.

    What I found is that PHP-FIG have a convention to use exact versions for implementations: https://www.php-fig.org/bylaws/psr-naming-conventions/

    ... Implementors of that PSR can then provide "psr/<package>-implementation": "1.0.0" in their package to satisfy that requirement ...

    opened by eclipxe13 2
  • Could mark as provide `psr/http-client-implementation`?

    Could mark as provide `psr/http-client-implementation`?

    This package implements contains in composer.json:

    "provide": {
        "php-http/client-implementation": "1.0"
    }
    

    Could you please add "psr/http-client-implementation": "^1.0" so your package can satisfy this virtual package?

    Thanks for your great work!

    opened by eclipxe13 2
  • Enhance tests

    Enhance tests

    Changed log

    • Add ext-curl extension to check whether this extension is loaded correctly during composer installation.
    • Add expectExceptionMessage to check the expected exception message is same as result message.
    enhancement 
    opened by peter279k 2
  • Update dependency cimg/php to v8.1

    Update dependency cimg/php to v8.1

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | cimg/php | docker | minor | 8.0 -> 8.1 | | cimg/php | docker | major | 7.4 -> 8.1 | | cimg/php | docker | major | 7.3 -> 8.1 | | cimg/php | docker | major | 7.2 -> 8.1 | | cimg/php | docker | major | 7.1 -> 8.1 |


    Configuration

    📅 Schedule: At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    â™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about these updates again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.

    opened by renovate[bot] 1
  • Update dependency cimg/php to v7.4

    Update dependency cimg/php to v7.4

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | cimg/php | docker | minor | 7.3 -> 7.4 | | cimg/php | docker | minor | 7.2 -> 7.4 | | cimg/php | docker | minor | 7.1 -> 7.4 |


    Configuration

    📅 Schedule: At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    â™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about these updates again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.

    opened by renovate[bot] 1
  • Update dependency phpunit/phpunit to v7.5.6

    Update dependency phpunit/phpunit to v7.5.6

    This PR contains the following updates:

    | Package | Type | Update | Change | References | |---|---|---|---|---| | phpunit/phpunit | require-dev | patch | 7.5.1 -> 7.5.6 | homepage, source |


    Release Notes

    sebastianbergmann/phpunit

    v7.5.6

    Compare Source

    v7.5.5

    Compare Source

    v7.5.4

    Compare Source

    v7.5.3

    Compare Source

    v7.5.2

    Compare Source


    Renovate configuration

    :date: Schedule: At any time (no schedule defined).

    :vertical_traffic_light: Automerge: Disabled by config. Please merge this manually once you are satisfied.

    :recycle: Rebasing: Whenever PR becomes conflicted, or if you modify the PR title to begin with "rebase!".

    :no_bell: Ignore: Close this PR and you won't be reminded about this update again.


    • [x] If you want to rebase/retry this PR, check this box

    This PR has been generated by Renovate Bot. View repository job log here.

    opened by renovate[bot] 1
  • Update dependency sunrise/http-factory to v2.0.2

    Update dependency sunrise/http-factory to v2.0.2

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | sunrise/http-factory | require-dev | patch | 2.0.0 -> 2.0.2 |


    Release Notes

    sunrise-php/http-factory

    v2.0.2

    Compare Source

    • Insignificant changes.

    v2.0.1

    Compare Source

    • Minor changes.

    Configuration

    📅 Schedule: At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    â™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.

    opened by renovate[bot] 0
  • Update dependency sunrise/http-factory to v1.1.1 - autoclosed

    Update dependency sunrise/http-factory to v1.1.1 - autoclosed

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | sunrise/http-factory | require-dev | patch | 1.1.0 -> 1.1.1 |


    Release Notes

    sunrise-php/http-factory

    v1.1.1

    Compare Source

    • Minor changes.

    Configuration

    📅 Schedule: At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    â™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.

    opened by renovate[bot] 0
  • Update dependency circleci/php to v8 - autoclosed

    Update dependency circleci/php to v8 - autoclosed

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | circleci/php | docker | major | 7.4-cli-node-browsers -> 8.0-cli-node-browsers | | circleci/php | docker | major | 7.3-cli-node-browsers -> 8.0-cli-node-browsers | | circleci/php | docker | major | 7.2-cli-node-browsers -> 8.0-cli-node-browsers | | circleci/php | docker | major | 7.1-cli-node-browsers -> 8.0-cli-node-browsers |


    Configuration

    📅 Schedule: At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    â™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about these updates again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.

    opened by renovate[bot] 0
  • Dependency Dashboard

    Dependency Dashboard

    This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

    This repository currently has no open or pending branches.

    Detected dependencies

    composer
    composer.json
    • php >=7.1
    • psr/http-client ^1.0
    • psr/http-factory ^1.0
    • psr/http-message ^1.0
    • sunrise/coding-standard 1.0.0
    • sunrise/http-factory 2.0.2

    • [ ] Check this box to trigger a request for Renovate to run again on this repository
    opened by renovate[bot] 0
Releases(v1.4.6)
Owner
Sunrise // PHP
Sunrise // PHP
A Chainable, REST Friendly, PHP HTTP Client. A sane alternative to cURL.

Httpful Httpful is a simple Http Client library for PHP 7.2+. There is an emphasis of readability, simplicity, and flexibility – basically provide the

Nate Good 1.7k Dec 21, 2022
PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs

PHP Curl Class: HTTP requests made easy PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs. Installation Requirements Quic

null 3.1k Jan 5, 2023
Online tool to convert `curl` requests to Laravel `Http` requests

curl Converter Another bit of automation from Shift to convert curl requests to Laravel Http requests. This project is a WIP. You may follow along wit

Laravel Shift 66 Dec 17, 2022
HTTP header kit for PHP 7.1+ (incl. PHP 8) based on PSR-7

HTTP header kit for PHP 7.1+ (incl. PHP 8) based on PSR-7 Installation composer require sunrise/http-header-kit How to use? HTTP Header Collection Mor

Sunrise // PHP 63 Dec 31, 2022
Simple PHP curl wrapper class

php-curl The smallest possible OOP wrapper for PHP's curl capabilities. Note that this is not meant as a high-level abstraction. You should still know

Andreas Lutro 243 Dec 5, 2022
Async HTTP/1.1+2 client for PHP based on Amp.

This package provides an asynchronous HTTP client for PHP based on Amp. Its API simplifies standards-compliant HTTP resource traversal and RESTful web

AMPHP 641 Dec 19, 2022
PSR-7 HTTP Message implementation

zend-diactoros Repository abandoned 2019-12-31 This repository has moved to laminas/laminas-diactoros. Master: Develop: Diactoros (pronunciation: /dɪʌ

Zend Framework 1.6k Dec 9, 2022
PSR HTTP Message implementations

laminas-diactoros Diactoros (pronunciation: /dɪʌktɒrɒs/): an epithet for Hermes, meaning literally, "the messenger." This package supercedes and repla

Laminas Project 343 Dec 25, 2022
Zenscrape package is a simple PHP HTTP client-provider that makes it easy to parsing site-pages

Zenscrape package is a simple PHP HTTP client-provider that makes it easy to parsing site-pages

Andrei 3 Jan 17, 2022
PHP Curl ile letgo api kütüphanesi oluşturuldu. php ile letgo giriş yap.

Kendi LETGO API ile iÅŸlemler gerçekleÅŸtirelim. // email iÅŸlemleri $server = 'imap.gmail.com'; $user = '[email protected]'; $pass = 'password'; $port = 9

Görkem Bayraktar 2 Nov 3, 2022
Declarative HTTP Clients using Guzzle HTTP Library and PHP 8 Attributes

Waffler How to install? $ composer require waffler/waffler This package requires PHP 8 or above. How to test? $ composer phpunit Quick start For our e

Waffler 3 Aug 26, 2022
The best php curl library.

中文文档 About Implemented by using php-curl internal io event with high performance,high universality,high extensibility which especially suitable for ma

Ares 431 Dec 12, 2022
Custom PHP curl library for the Laravel 5 framework - developed by Ixudra

ixudra/curl Custom PHP cURL library for the Laravel 4 or 5 framework - developed by Ixudra. The package provides an easy interface for sending cURL re

Jan Oris 556 Jan 6, 2023
PHP cURL for feed Instagram Graph API

php-curl-instagram-graph PHP cURL for feed Instagram Graph API Script made based on the new (2020) Instagram API that requires authorization token gen

null 12 Apr 13, 2022
This library provides an object-oriented wrapper of the PHP cURL extension

PHP Curl Class This library provides an object-oriented wrapper of the PHP cURL extension. If you have questions or problems with installation or usag

PHP MOD 321 Dec 30, 2022
The best php curl library.

中文文档 About Implemented by using php-curl internal io event with high performance,high universality,high extensibility which especially suitable for ma

Ares 431 Dec 12, 2022
Plug & Play [CURL + Composer Optional], Proxy as a Service, Multi-tenant, Multi-Threaded, with Cache & Article Spinner

?? .yxorP The SAAS(y), Multitenancy & Augmenting Web Proxy Guzzler is a 100% SAAS(y) plug-and-play (PHP CURL+Composer are Optional) solution that leverages SAAS architecture to provide multi-tenancy, multiple threads, caching, and an article spinner service.

4D/Òµ.com Dashboards 12 Nov 17, 2022
Guzzle, an extensible PHP HTTP client

Guzzle, PHP HTTP client Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services. Simple interf

Guzzle 22.3k Jan 2, 2023
PHP's lightweight HTTP client

Buzz - Scripted HTTP browser Buzz is a lightweight (<1000 lines of code) PHP 7.1 library for issuing HTTP requests. The library includes three clients

Kris Wallsmith 1.9k Jan 4, 2023