PHPackages                             dpc/guzzle-client - 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. dpc/guzzle-client

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

dpc/guzzle-client
=================

Simple Guzzle Client for a Laravel application

v0.4.2(7y ago)116737MITPHPPHP &gt;=7.1

Since Aug 16Pushed 7y ago3 watchersCompare

[ Source](https://github.com/Dylan-DPC/guzzle-client)[ Packagist](https://packagist.org/packages/dpc/guzzle-client)[ RSS](/packages/dpc-guzzle-client/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (3)Versions (12)Used By (0)

What is this?
=============

[](#what-is-this)

[![MIT licensed](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](./LICENSE)[![Latest Stable Version](https://camo.githubusercontent.com/6c7666365432e5def88016f42423d6ecadfa30c582c9ba15c26741c972f151b4/68747470733a2f2f706f7365722e707567782e6f72672f6470632f67757a7a6c652d636c69656e742f762f737461626c652e737667)](https://packagist.org/packages/dpc/guzzle-client)

A Simple Guzzle Client for a Laravel application

Requirements
============

[](#requirements)

- PHP 7.1 or higher
- Laravel 5.5 or 5.6

Installation
============

[](#installation)

Via composer

```
$ composer require dpc/guzzle-client
```

Usage
=====

[](#usage)

Inject the contract into the class where you need the client:

```
/**
 * @var RequestClientContract
 */
protected $client;

/**
 * @param RequestClientContract $client
 */
public function __construct(RequestClientContract $client)
{
    $this->client = $client;
}
```

You can then use the client by first calling make, to set the base URI - and then populating the request. The client returns a normal PSR ResponseInterface. This means you interact with the response as you would with any Guzzle response.

```
$client = $this->client->make('https://httpbin.org/');

$client->to('get')->withBody([
	'foo' => 'bar'
])->withHeaders([
	'baz' => 'qux'
])->withOptions([
	'allow_redirects' => false
])->asJson()->get();

echo $response->getBody();
echo $response->getStatusCode();
```

Alternatively, you can include both the body, headers and options in a single call.

```
$client = $this->client->make('https://httpbin.org/');

$response = $client->to('get')->with([
    'foo' => 'bar'
], [
    'baz' => 'qux'
], [
    'allow_redirects' => false
])->asFormParams()->get();

echo $response->getBody();
echo $response->getStatusCode();
```

The `asJson()` method will send the data using `json` key in the Guzzle request. (You can use `asFormParams()` to send the request as form params).

Available methods / Example Usage
=================================

[](#available-methods--example-usage)

```
$client = $this->client->make('https://httpbin.org/');

// Get request
$response = $client->to('brotli')->get();

// Post request
$response = $client->to('post')->withBody([
	'foo' => 'bar'
])->asJson()->post();

// Put request
$response = $client->to('put')->withBody([
	'foo' => 'bar'
])->asJson()->put();

// Patch request
$response = $client->to('patch')->withBody([
	'foo' => 'bar'
])->asJson()->patch();

// Delete request
$response = $client->to('delete?id=1')->delete();

// Headers are easily added using the withHeaders method
$response = $client->to('get')->withHeaders([
	'Authorization' => 'Bearer fooBar'
])->asJson()->get();

// Custom options can be specified for the Guzzle instance
$response = $client->to('redirect/5')->withOptions([
	'allow_redirects' => [
		'max' => 5,
		'protocols' => [
			'http',
			'https'
		]
	]
])->get();

// You can also specify the request method as a string
$response = $client->to('post')->withBody([
	'foo' => 'bar'
])->asJson()->request('post');
```

Debugging
=========

[](#debugging)

Using `debug(bool|resource)` before sending a request turns on Guzzle's debugger, more information about that [here](http://docs.guzzlephp.org/en/stable/request-options.html#debug).

The debugger is turned off after every request, if you need to debug multiple requests sent sequentially you will need to turn on debugging for all of them.

**Example**

```
$logFile = './guzzle_client_debug_test.log';
$logFileResource = fopen($logFile, 'w+');

$client->debug($logFileResource)->to('post')->withBody([
	'foo' => 'random data'
])->asJson()->post();

fclose($logFileResource);
```

This writes Guzzle's debug information to `guzzle_client_debug_test.log`.

Versioning
==========

[](#versioning)

This package follows [semver](http://semver.org/). Features introduced &amp; any breaking changes created in major releases are mentioned in [releases](https://github.com/Dylan-DPC/guzzle-client/releases).

Support
=======

[](#support)

This package is created as a basic wrapper for Guzzle based on what I needed in a few projects. If you need any other features of Guzzle, you can create a issue here or send a PR to master branch.

If you need help or have any questions you can:

- [Create an issue here](https://github.com/Dylan-DPC/guzzle-client/issues/new)
- [Send a tweet to @DPC\_22](https://twitter.com/DPC_22)
- Email me at
- DM me on the [larachat](https://larachat.co/) slack team (@Dylan DPC)

Authors
=======

[](#authors)

[Dylan DPC](https://github.com/Dylan-DPC)

License
=======

[](#license)

[The MIT License (MIT)](LICENSE)

Copyright (c) 2017 Dylan DPC

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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 ~45 days

Recently: every ~84 days

Total

10

Last Release

2782d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3222a40774e99df295dc842ab4886dc891a52f96da3ad05d7f89b6fe4018bc00?d=identicon)[DPC](/maintainers/DPC)

---

Top Contributors

[![Dylan-DPC](https://avatars.githubusercontent.com/u/99973273?v=4)](https://github.com/Dylan-DPC "Dylan-DPC (26 commits)")[![jordyvandomselaar](https://avatars.githubusercontent.com/u/12712484?v=4)](https://github.com/jordyvandomselaar "jordyvandomselaar (3 commits)")[![CmdrSharp](https://avatars.githubusercontent.com/u/5938745?v=4)](https://github.com/CmdrSharp "CmdrSharp (2 commits)")[![wotta](https://avatars.githubusercontent.com/u/13332240?v=4)](https://github.com/wotta "wotta (2 commits)")[![connectkushal](https://avatars.githubusercontent.com/u/19621775?v=4)](https://github.com/connectkushal "connectkushal (1 commits)")[![Lloople](https://avatars.githubusercontent.com/u/5665466?v=4)](https://github.com/Lloople "Lloople (1 commits)")[![ntzm](https://avatars.githubusercontent.com/u/3888578?v=4)](https://github.com/ntzm "ntzm (1 commits)")[![pajoda](https://avatars.githubusercontent.com/u/10170068?v=4)](https://github.com/pajoda "pajoda (1 commits)")[![tarlepp](https://avatars.githubusercontent.com/u/595561?v=4)](https://github.com/tarlepp "tarlepp (1 commits)")[![devronhansen](https://avatars.githubusercontent.com/u/20226404?v=4)](https://github.com/devronhansen "devronhansen (1 commits)")

---

Tags

guzzlehttplaravel

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dpc-guzzle-client/health.svg)

```
[![Health](https://phpackages.com/badges/dpc-guzzle-client/health.svg)](https://phpackages.com/packages/dpc-guzzle-client)
```

###  Alternatives

[illuminate/http

The Illuminate Http package.

11936.0M5.1k](/packages/illuminate-http)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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