GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - guzzle/command: Provides the foundation for building web service clients with Guzzle

BranchesTags
Open more actions menu

Latest commit

 

History

241 Commits
241 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
docs
docs
 
 
src
src
 
 
tests
tests
 
 
vendor-bin
vendor-bin
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.php-cs-fixer.dist.php
.php-cs-fixer.dist.php
 
 
AGENTS.md
AGENTS.md
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CLAUDE.md
CLAUDE.md
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
UPGRADING.md
UPGRADING.md
 
 
composer.json
composer.json
 
 
phpstan-baseline.neon
phpstan-baseline.neon
 
 
phpstan.neon.dist
phpstan.neon.dist
 
 
phpunit.xml.dist
phpunit.xml.dist
 
 

Repository files navigation

Guzzle Command

Guzzle Command provides the foundation for building command-based web service clients on top of Guzzle. A command represents one service operation, and a result represents the processed response from that operation.

Use this package when you are building an SDK-style client with named operations such as listUsers() or createOrder(). If you only need to send ordinary HTTP requests, install guzzlehttp/guzzle instead.

For declarative service descriptions that define operations from API metadata, see Guzzle Services.

Installation

composer require guzzlehttp/command

Version Guidance

Version Status PHP Version
2.0 Latest >=7.4,<8.7
1.5 Maintenance >=7.2.5,<8.7

Quick Start

use GuzzleHttp\Client as HttpClient;
use GuzzleHttp\Command\CommandInterface;
use GuzzleHttp\Command\Result;
use GuzzleHttp\Command\ResultInterface;
use GuzzleHttp\Command\ServiceClient;
use GuzzleHttp\Psr7\Request;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

$client = new ServiceClient(
    new HttpClient(['base_uri' => 'https://api.example.com']),
    function (CommandInterface $command): RequestInterface {
        return new Request(
            'POST',
            '/' . rawurlencode($command->getName()),
            ['Content-Type' => 'application/json'],
            \json_encode($command->toArray(), \JSON_THROW_ON_ERROR)
        );
    },
    function (
        ResponseInterface $response,
        RequestInterface $request,
        CommandInterface $command
    ): ResultInterface {
        return new Result(\json_decode((string) $response->getBody(), true, 512, \JSON_THROW_ON_ERROR));
    }
);

$result = $client->createUser(['name' => 'Ada']);

The service client can also execute commands asynchronously and run many commands with a configurable concurrency limit.

Documentation

  • Service Clients
  • Executing Commands
  • Async and Concurrency
  • Middleware: Extending the Client
  • Upgrade Guide
  • Changelog

Security

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

License

Guzzle Command 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.

About

Provides the foundation for building web service clients with Guzzle

Topics

guzzleguzzle-servicesmiddlewarepromises

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

115 stars

Watchers

9 watching

Forks

21 forks
Report repository

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.