PHPackages                             liopoos/booze - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. liopoos/booze

ActiveLibrary[HTTP &amp; Networking](/categories/http)

liopoos/booze
=============

A simple HTTP library based on Guzzle

v1.2.3(1y ago)025MITPHPPHP ^7.3

Since Jul 6Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/liopoos/booze)[ Packagist](https://packagist.org/packages/liopoos/booze)[ RSS](/packages/liopoos-booze/feed)WikiDiscussions master Synced today

READMEChangelog (6)Dependencies (3)Versions (13)Used By (0)

Booze
=====

[](#booze)

[![Latest Version](https://camo.githubusercontent.com/32c2e42d5f8621ba4c5f8381232477868790e234433cad23cb2b9b70773a785e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c696f706f6f732f626f6f7a652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/liopoos/booze)[![License](https://camo.githubusercontent.com/87536d5b889f52c8ce079a83b7e4dfe2e10597588279b4dda606ac9b1200858d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c696f706f6f732f626f6f7a652e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/39c97587d283e3389b807edd9ea9032fb06d61304a09696a73b8edd5dc6f97d4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6c696f706f6f732f626f6f7a652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/liopoos/booze)

A simple and elegant HTTP client library for PHP, built on top of Guzzle. Booze provides a clean, fluent interface for making HTTP requests with automatic response parsing, middleware support, and comprehensive error handling.

Features
--------

[](#features)

- 🚀 **Simple &amp; Intuitive API** - Clean, fluent interface for making HTTP requests
- 🔄 **Automatic Response Parsing** - Smart content-type detection and parsing (JSON, XML, plain text)
- 🛡️ **Built-in Error Handling** - Automatic exception throwing for HTTP error responses
- ⚙️ **Middleware Support** - Easy request/response manipulation with Guzzle middleware
- 📦 **Multiple Request Types** - Support for GET, POST, PUT, PATCH, DELETE with various content types
- 🎯 **Type-Safe** - Full type hints and return types for better IDE support

Requirements
------------

[](#requirements)

- PHP 7.3 or higher
- ext-json
- ext-simplexml

Installation
------------

[](#installation)

Install via Composer:

```
composer require liopoos/booze
```

Quick Start
-----------

[](#quick-start)

```
use Liopoos\Booze\Client;

class ApiClient extends Client
{
    public function __construct(array $guzzleOptions = [])
    {
        // Configure Guzzle options
        $guzzleOptions = array_merge([
            'base_uri' => 'https://api.example.com',
            'timeout' => 30,
        ], $guzzleOptions);

        parent::__construct($guzzleOptions);
    }
}

$client = new ApiClient();
$response = $client->get('/users');
```

Usage
-----

[](#usage)

### Basic HTTP Methods

[](#basic-http-methods)

#### GET Request

[](#get-request)

```
// Simple GET request
$response = $client->get('https://httpbin.org/get');

// GET with query parameters
$response = $client->get('https://httpbin.org/get', [
    'page' => 1,
    'limit' => 10
]);

// GET with custom headers
$response = $client->get('https://httpbin.org/get', [], [
    'Authorization' => 'Bearer token123'
]);
```

#### POST Request

[](#post-request)

```
// POST with form data
$response = $client->post('https://httpbin.org/post', [
    'name' => 'John Doe',
    'email' => 'john@example.com'
]);

// POST with JSON
$response = $client->postJson('https://httpbin.org/post', [
    'name' => 'John Doe',
    'email' => 'john@example.com'
]);

// POST with multipart (file uploads)
$response = $client->postMultiPart('https://httpbin.org/post', [
    [
        'name' => 'file',
        'contents' => fopen('/path/to/file.jpg', 'r'),
        'filename' => 'file.jpg'
    ]
]);
```

#### PUT Request

[](#put-request)

```
// PUT with form data
$response = $client->put('https://httpbin.org/put', [
    'name' => 'Jane Doe'
]);

// PUT with JSON
$response = $client->putJson('https://httpbin.org/put', [
    'name' => 'Jane Doe'
]);

// PUT with multipart
$response = $client->putMultiPart('https://httpbin.org/put', [
    [
        'name' => 'data',
        'contents' => 'value'
    ]
]);
```

#### PATCH Request

[](#patch-request)

```
// PATCH with JSON (default)
$response = $client->patch('https://httpbin.org/patch', [
    'name' => 'Updated Name'
]);
```

#### DELETE Request

[](#delete-request)

```
// Simple DELETE
$response = $client->delete('https://httpbin.org/delete');

// DELETE with JSON body
$response = $client->deleteJson('https://httpbin.org/delete', [
    'reason' => 'No longer needed'
]);
```

### Working with Headers

[](#working-with-headers)

Set persistent headers for all requests:

```
$client->withHeaders([
    'Authorization' => 'Bearer your-token',
    'Accept' => 'application/json',
    'User-Agent' => 'MyApp/1.0'
]);

// All subsequent requests will include these headers
$response = $client->get('https://api.example.com/data');
```

### Response Handling

[](#response-handling)

Booze automatically parses responses based on the `Content-Type` header:

```
// JSON responses are automatically decoded to arrays
$response = $client->get('https://api.example.com/users');
// $response is an array

// XML responses are converted to arrays
$response = $client->get('https://api.example.com/data.xml');
// $response is an array

// Plain text responses are returned as strings
$response = $client->get('https://example.com/text');
// $response is a string
```

### Error Handling

[](#error-handling)

Booze provides specific exceptions for common HTTP errors:

```
use Liopoos\Booze\Exception\UnauthorizedHttpException;
use Liopoos\Booze\Exception\NotFoundHttpException;
use Liopoos\Booze\Exception\AccessDeniedHttpException;
use Liopoos\Booze\Exception\ApiException;

try {
    $response = $client->get('https://api.example.com/protected');
} catch (UnauthorizedHttpException $e) {
    // Handle 401 Unauthorized
    echo "Authentication failed: " . $e->getMessage();
} catch (AccessDeniedHttpException $e) {
    // Handle 403 Forbidden
    echo "Access denied: " . $e->getMessage();
} catch (NotFoundHttpException $e) {
    // Handle 404 Not Found
    echo "Resource not found: " . $e->getMessage();
} catch (ApiException $e) {
    // Handle all other HTTP errors (4xx, 5xx)
    echo "API error: " . $e->getMessage();
}
```

### Advanced Usage

[](#advanced-usage)

#### Custom Guzzle Configuration

[](#custom-guzzle-configuration)

```
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;

class MyApiClient extends Client
{
    public function __construct()
    {
        $handler = HandlerStack::create();

        // Add custom middleware
        $handler->push(Middleware::log(
            $logger,
            new MessageFormatter('{method} {uri} HTTP/{version} {code}')
        ));

        parent::__construct([
            'handler' => $handler,
            'base_uri' => 'https://api.example.com',
            'timeout' => 30,
            'verify' => true,
            'http_errors' => false,
        ]);
    }
}
```

#### Accessing Raw Guzzle Client and Response

[](#accessing-raw-guzzle-client-and-response)

```
// Get the underlying Guzzle client
$guzzleClient = $client->getHttpClient();

// Get the last HTTP response object
$client->get('https://httpbin.org/get');
$httpResponse = $client->getHttpResponse();

// Access response details
$statusCode = $httpResponse->getStatusCode();
$headers = $httpResponse->getHeaders();
$body = $httpResponse->getBody();
```

API Reference
-------------

[](#api-reference)

### Client Methods

[](#client-methods)

#### HTTP Methods

[](#http-methods)

MethodDescriptionParameters`get(string $url, array $query = [], array $headers = [])`Send GET requestURL, query parameters, headers`post(string $url, array $body = [], array $headers = [])`Send POST with form dataURL, form data, headers`postJson(string $url, array $body, array $headers = [])`Send POST with JSONURL, JSON data, headers`postMultiPart(string $url, array $body, array $headers = [])`Send POST with multipartURL, multipart data, headers`put(string $url, array $body = null, array $headers = [])`Send PUT with form dataURL, form data, headers`putJson(string $url, array $body = null, array $headers = [])`Send PUT with JSONURL, JSON data, headers`putMultiPart(string $url, array $body = null, array $headers = [])`Send PUT with multipartURL, multipart data, headers`patch(string $url, array $body = [], array $headers = [])`Send PATCH with JSONURL, JSON data, headers`delete(string $url, array $headers = [])`Send DELETE requestURL, headers`deleteJson(string $url, array $body = [], array $headers = [])`Send DELETE with JSONURL, JSON data, headers#### Utility Methods

[](#utility-methods)

MethodDescriptionReturns`withHeaders(array $headers)`Set persistent headers for all requests`Client` (chainable)`getHttpClient()`Get the underlying Guzzle client`\GuzzleHttp\Client``getHttpResponse()`Get the last HTTP response object`\GuzzleHttp\Psr7\Response`### Exceptions

[](#exceptions)

ExceptionHTTP StatusDescription`UnauthorizedHttpException`401Authentication required or failed`AccessDeniedHttpException`403Access forbidden`NotFoundHttpException`404Resource not found`ApiException`Other 4xx/5xxGeneric API errorAll exceptions extend `\GuzzleHttp\Exception\TransferException`.

Testing
-------

[](#testing)

Run the test suite:

```
# Run all tests
./vendor/bin/phpunit

# Run with detailed output
./vendor/bin/phpunit --testdox

# Run with code coverage
./vendor/bin/phpunit --coverage-html coverage
```

See [tests/README.md](tests/README.md) for more information about the test suite.

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

This library is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

Credits
-------

[](#credits)

- Built on top of [Guzzle HTTP Client](https://github.com/guzzle/guzzle)
- Developed by [hades](mailto:hades_dev@foxmail.com)

Support
-------

[](#support)

If you encounter any issues or have questions, please [open an issue](https://github.com/liopoos/booze/issues) on GitHub.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance52

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~153 days

Recently: every ~230 days

Total

7

Last Release

536d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/45413?v=4)[hades](/maintainers/hades)[@hades](https://github.com/hades)

---

Top Contributors

[![liopoos](https://avatars.githubusercontent.com/u/12404909?v=4)](https://github.com/liopoos "liopoos (21 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/liopoos-booze/health.svg)

```
[![Health](https://phpackages.com/badges/liopoos-booze/health.svg)](https://phpackages.com/packages/liopoos-booze)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M47](/packages/tencentcloud-tencentcloud-sdk-php)[guzzlehttp/guzzle-services

Provides an implementation of the Guzzle Command library that uses Guzzle service descriptions to describe web services, serialize requests, and parse responses into easy to use model structures.

25711.0M191](/packages/guzzlehttp-guzzle-services)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
