Giter Club home page Giter Club logo

command's Introduction

Guzzle

Guzzle, PHP HTTP client

Latest Version Build Status Total Downloads

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

  • Simple interface for building query strings, POST requests, streaming large uploads, streaming large downloads, using HTTP cookies, uploading JSON data, etc...
  • Can send both synchronous and asynchronous requests using the same interface.
  • Uses PSR-7 interfaces for requests, responses, and streams. This allows you to utilize other PSR-7 compatible libraries with Guzzle.
  • Supports PSR-18 allowing interoperability between other PSR-18 HTTP Clients.
  • Abstracts away the underlying HTTP transport, allowing you to write environment and transport agnostic code; i.e., no hard dependency on cURL, PHP streams, sockets, or non-blocking event loops.
  • Middleware system allows you to augment and compose client behavior.
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle');

echo $response->getStatusCode(); // 200
echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
echo $response->getBody(); // '{"id": 1420053, "name": "guzzle", ...}'

// Send an asynchronous request.
$request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org');
$promise = $client->sendAsync($request)->then(function ($response) {
    echo 'I completed! ' . $response->getBody();
});

$promise->wait();

Help and docs

We use GitHub issues only to discuss bugs and new features. For support please refer to:

Installing Guzzle

The recommended way to install Guzzle is through Composer.

composer require guzzlehttp/guzzle

Version Guidance

Version Status Packagist Namespace Repo Docs PSR-7 PHP Version
3.x EOL (2016-10-31) guzzle/guzzle Guzzle v3 v3 No >=5.3.3,<7.0
4.x EOL (2016-10-31) guzzlehttp/guzzle GuzzleHttp v4 N/A No >=5.4,<7.0
5.x EOL (2019-10-31) guzzlehttp/guzzle GuzzleHttp v5 v5 No >=5.4,<7.4
6.x EOL (2023-10-31) guzzlehttp/guzzle GuzzleHttp v6 v6 Yes >=5.5,<8.0
7.x Latest guzzlehttp/guzzle GuzzleHttp v7 v7 Yes >=7.2.5,<8.4

Security

If you discover a security vulnerability within this package, please send an email to [email protected]. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. Please see Security Policy for more information.

License

Guzzle is made available under the MIT License (MIT). Please see License File for more information.

For Enterprise

Available as part of the Tidelift Subscription

The maintainers of Guzzle and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

command's People

Contributors

bolid1 avatar bumbummen99 avatar elyobo avatar grahamcampbell avatar hpatoio avatar jeremeamia avatar konafets avatar mtdowling avatar robinvdvleuten avatar seiffert avatar tianyiw2013 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

command's Issues

Update Version

The batch method is not included in the AbstractClient in 0.4.0.

Any chance we can tag the most recent code?

How to migrate from 0.8 to 0.9?

Hello,
Could you please explain a bit how to migrate from 0.8 to 0.9 to replace Event system please?

EDIT
I suppose I can find the answer here

Exception "CommandClientException" returns code 0 instead of the HTTP error code

Example: server replies to my request with a code 409 HTTP error.
The following code prints 0 instead of 409.

try {    
   $response = $guzzleClient->execute($command);  
} catch (\GuzzleHttp\Command\Exception\CommandClientException $e) {  
    echo $e->getCode();
}

For example \GuzzleHttp\Exception\ClientException 's code is the HTTP code.
Am I missing something?

[Question] How client communicate with command?

Correct me if i am wrong but as far as i read documentation i am not able to understand how $client is able to interact with $command?.

  1. Do $client HTTP response is passed to $command?
  2. Do $client do all validation stuffs and when all things passes then $command will be executed?

Add some documentation about instantiate a client

The readme is lacking a documentation for instantiation of the client. For now I got inspired by the unit tests but for some reasons I will receive a 400 Bad Request while sending form encoded params to an URL.

Is there going to be a ModelInterface?

Event listeners are attached to the client to handle creating HTTP requests for a command, processing HTTP responses into a result (typically a GuzzleHttp\Command\ModelInterface)

It sounds like a good idea, but I don't see this interface in the repository.

guzzle 6 requirements problem

Hello,

I'm trying to use guzzle/guzzle-services with guzzle 6, but the fact that guzzle/guzzle-services require guzzle/command and that guzzle command require guzzle "~5.0" makes it complicate (impossible) and I get stuck with guzzle 5.3.

How to reproduce:
$ composer require guzzlehttp/guzzle
Using version ^6.1 for guzzlehttp/guzzle
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)

  • Installing guzzlehttp/promises (1.0.2)
    Downloading: 100%
  • Installing psr/http-message (1.0)
    Downloading: 100%
  • Installing guzzlehttp/psr7 (1.2.0)
    Downloading: 100%
  • Installing guzzlehttp/guzzle (6.1.0)
    Downloading: 100%

Writing lock file
Generating autoload files

$ composer require guzzlehttp/guzzle-services
Using version ^0.5.0 for guzzlehttp/guzzle-services
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- guzzlehttp/command 0.7.1 requires guzzlehttp/guzzle ~5.0 -> no matching package found.
- guzzlehttp/command 0.7.0 requires guzzlehttp/guzzle ~5.0 -> no matching package found.
- guzzlehttp/guzzle-services 0.5.0 requires guzzlehttp/command 0.7.* -> satisfiable by guzzlehttp/command[0.7.0, 0.7.1].
- Installation request for guzzlehttp/guzzle-services ^0.5.0 -> satisfiable by guzzlehttp/guzzle-services[0.5.0].

Potential causes:

Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

Installation failed, reverting ./composer.json to its original content.

Thanks in advance

Easily throw own exceptions?

Hi,

In Guzzle 3, I had listeners to catch events, and throw business specific exceptions. For instance, this was the list of exceptions: https://github.com/zf-fr/zfr-mailchimp/tree/v2.0.5/src/ZfrMailChimp/Exception

And I had a listener that used to inspect the response and trigger those exceptions: https://github.com/zf-fr/zfr-mailchimp/blob/v2.0.5/src/ZfrMailChimp/Client/Listener/ErrorHandlerListener.php

However, I can't make work that on Guzzle 4. My new listener looks like that: https://github.com/zf-fr/zfr-mailchimp/blob/master/src/ZfrMailChimp/Client/Listener/ErrorHandlerListener.php

But Guzzle always wrap my own exception around a RequestException (first), and wrap again around a CommandException. Therefore, this prevents me from catching the MailChimp specific exceptions.

How can I force Guzzle NOT TO wrap my exceptions emitted in the listener?

Thanks!

Extension/Resuse Documentation

I'm trying to use this functionality as a basis for an API library.

Is there documentation for the best way to use/implement it? IE. new CurrindaAPIService which sets up all endpoints etc?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.