PHPackages                             imahmood/laravel-http-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. imahmood/laravel-http-client

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

imahmood/laravel-http-client
============================

Laravel HTTP Client Wrapper

v1.6.0(5mo ago)310.9kMITPHPPHP ^8.1CI passing

Since Sep 17Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/imahmood/laravel-http-client)[ Packagist](https://packagist.org/packages/imahmood/laravel-http-client)[ RSS](/packages/imahmood-laravel-http-client/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (7)Versions (10)Used By (0)

Laravel HTTP Client Wrapper
===========================

[](#laravel-http-client-wrapper)

[![Latest Stable Version](https://camo.githubusercontent.com/c62831326ed54eac4f5293030fdf4abf1c82c399edf41dce67098d17712acfc7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696d61686d6f6f642f6c61726176656c2d687474702d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/imahmood/laravel-http-client)[![GitHub Tests Action Status](https://camo.githubusercontent.com/ea8ea3b9b6e82aee166fa00641dbf6fe111338660a952d93b197710cad1c713f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f696d61686d6f6f642f6c61726176656c2d687474702d636c69656e742f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/imahmood/laravel-http-client/actions?query=workflow%3Atests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/d47c8312760998ec8e3b8855aecdb62953fd27f2200467d4d666972b2ac24d68/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696d61686d6f6f642f6c61726176656c2d687474702d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/imahmood/laravel-http-client)[![License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

This is a simple wrapper around Laravel's HTTP Client that simplifies making HTTP requests and handling responses. It provides an easy-to-use interface for common HTTP operations.

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

[](#installation)

You can install this package via Composer:

```
composer require imahmood/laravel-http-client

```

Usage
-----

[](#usage)

### Sending a GET Request

[](#sending-a-get-request)

To send a GET request, use the following code:

```
use Imahmood\HttpClient\Request;
use Imahmood\HttpClient\ClientFactory;

$request = new Request(HttpMethod::GET, 'https://example.com/api/users');
$response = ClientFactory::create()->send($request);
```

### Sending a POST Request

[](#sending-a-post-request)

To send a POST request, you can do it like this:

```
$body = [
    'username' => '__USERNAME__',
    'password' => '__PASSWORD__',
];

$request = new Request(HttpMethod::POST, 'https://example.com/api/auth/login', $body);
$response = ClientFactory::create()->send($request);
```

### Uploading Files

[](#uploading-files)

To upload files, attach them to the request using the `addFile` method:

```
$request = new Request(HttpMethod::POST, 'https://example.com/api/users/1/avatar', $body);
$request->addFile('avatar', '/home/user/avatar.png');

$response = ClientFactory::create()->send($request);
```

### Sending a Request with a Bearer Token

[](#sending-a-request-with-a-bearer-token)

If you need to send a request with a Bearer Token for authentication, you can do so like this:

```
$accessToken = '__TOKEN__';

$request = new Request(HttpMethod::GET, 'https://example.com/api/users', $body);
$response = ClientFactory::createWithBearerToken($accessToken)->send($request);
```

### Request duration

[](#request-duration)

You can easily retrieve the duration of a http request:

```
$response = ClientFactory::create()->send($request);

echo $response->duration();
```

### Handling Unsuccessful Responses

[](#handling-unsuccessful-responses)

You can easily throw an exception if the response is unsuccessful:

```
$response = ClientFactory::create()->send($request);

try {
    $response->validate();
} catch (\Imahmood\HttpClient\Exceptions\ServerException $e) {
    // Handle the exception here
} catch (\Imahmood\HttpClient\Exceptions\ClientException $e) {
    // Handle the exception here
} catch (\Illuminate\Validation\ValidationException $e) {
    // Handle the exception here
}
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance71

Regular maintenance activity

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

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

Recently: every ~53 days

Total

9

Last Release

163d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/40872fcebcb975a26597596c44e39a140269d1db23522b47831bfca04d3397f1?d=identicon)[imahmood](/maintainers/imahmood)

---

Top Contributors

[![imahmood](https://avatars.githubusercontent.com/u/13146816?v=4)](https://github.com/imahmood "imahmood (17 commits)")

---

Tags

http-clientlaravellaravel-http-clientlaravelhttp clientlaravel-http-client

###  Code Quality

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/imahmood-laravel-http-client/health.svg)

```
[![Health](https://phpackages.com/badges/imahmood-laravel-http-client/health.svg)](https://phpackages.com/packages/imahmood-laravel-http-client)
```

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[omniphx/forrest

A Laravel library for Salesforce

2724.4M8](/packages/omniphx-forrest)[sunchayn/nimbus

A Laravel package providing an in-browser API client with automatic schema generation, live validation, and built-in authentication with a touch of Laravel-tailored magic for effortless API testing.

29428.0k](/packages/sunchayn-nimbus)[rahul900day/laravel-captcha

Different types of Captcha implementation for Laravel Application.

10715.9k](/packages/rahul900day-laravel-captcha)[onlime/laravel-http-client-global-logger

A global logger for the Laravel HTTP Client

1935.1k](/packages/onlime-laravel-http-client-global-logger)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)

PHPackages © 2026

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