PHPackages                             omitobisam/laravel-habitue - 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. omitobisam/laravel-habitue

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

omitobisam/laravel-habitue
==========================

An Http client with the power of collections for your Jsonable requests

v4.2.0(1y ago)417[1 issues](https://github.com/omitobi/laravel-habitue/issues)MITPHPPHP &gt;=8.1CI failing

Since Mar 24Pushed 1y ago1 watchersCompare

[ Source](https://github.com/omitobi/laravel-habitue)[ Packagist](https://packagist.org/packages/omitobisam/laravel-habitue)[ Docs](https://omitobi.github.io/laravel-habitue/)[ RSS](/packages/omitobisam-laravel-habitue/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (4)Versions (14)Used By (0)

[![](https://github.com/omitobi/assets/raw/master/laravel-habitue-assets/twitter_header_photo_2.png)](https://github.com/omitobi/assets/blob/master/laravel-habitue-assets/twitter_header_photo_2.png)

[ ![Build Status](https://github.com/omitobi/laravel-habitue/actions/workflows/php.yml/badge.svg)](https://omitobi.github.io/laravel-habitue/)[ ![Latest Stable Version](https://camo.githubusercontent.com/cc6f38925b25f23336f2087cedfba036dbaf20f2714a72ffa6b89fc8780d8584/68747470733a2f2f706f7365722e707567782e6f72672f6f6d69746f626973616d2f6c61726176656c2d686162697475652f76657273696f6e)](https://packagist.org/packages/omitobisam/laravel-habitue)[ ![Total Downloads](https://camo.githubusercontent.com/b5aeee513de5e2ac43eabd35205c8db3022390f726ff73c94dfb7dfc06f122f3/68747470733a2f2f706f7365722e707567782e6f72672f6f6d69746f626973616d2f6c61726176656c2d686162697475652f646f776e6c6f616473)](https://packagist.org/packages/omitobisam/laravel-habitue)[ ![Latest Unstable Version](https://camo.githubusercontent.com/2fef2595471d83a2c53e72dfa6f592a8595e321b1b5d226b78f1919baef85b72/68747470733a2f2f706f7365722e707567782e6f72672f6f6d69746f626973616d2f6c61726176656c2d686162697475652f762f756e737461626c65)](https://packagist.org/packages/omitobisam/laravel-habitue)[ ![Latest Monthly Downloads](https://camo.githubusercontent.com/3a991cb249b59b51cd262f93ff7de0bff849869b024b7a492f36ed9abf4a581d/68747470733a2f2f706f7365722e707567782e6f72672f6f6d69746f626973616d2f6c61726176656c2d686162697475652f642f6d6f6e74686c79)](https://packagist.org/packages/omitobisam/laravel-habitue)

About Habitue
-------------

[](#about-habitue)

The easiest and fluent HTTP Client for PHP.

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

[](#installation)

Using composer:

`composer require omitobisam/laravel-habitue`

or add to the require object of `composer.json` file with the version number:

```
{
  "require": {
    "omitobisam/laravel-habitue": "^v3.0"
  }
}
```

After this run `composer update`

Usage
-----

[](#usage)

You can call the helper function simply:

```
$response = habitue('http://ninja.example/users')->get();
$response = habitue('http://ninja.example/users', ['data' => 'aaa'])->post();
$response = habitue('http://ninja.example/users')->delete();
$response = habitue('http://ninja.example/users', ['data' => 'aaa'])->patch();

$response->get('data')
```

You can call it simply statically:

```
use Habitue\Habitue;
Habitue::::make('http://ninja.example/api/users')->get(); // or ->post()
```

With Configuration:

```
use Habitue\Habitue;
// or simply
Habitue::::make('http://ninja.example/api/users') // An instance of Habitue
->setBody(['page' => 2]) //set body
->setHeaders(['x-key' => 'abcd']) // set header(s)
->get()
```

Handling Responses returned:

```
use Habitue\Habitue;

/**
* @var $response Habitue\Integration\Collector
*/
$response = habitue('http://ninja.example/users')->get();

$response->statusCode(); // int
$response->headers(); // array
$response->toJson(); // string
// And others method available in Illuminate\Collection

$clientResponse = $response->response(); // Habitue\Integration\ClientResponse
$clientResponse->getData(); // string
$clientResponse->getStatusCode(); // int
$clientResponse->getHeaders(); // array
```

The Response (as Habitue\\Integration\\Collector) is a smart Collection that provides all the methods available in Laravel Collection and helps to draw out values deeply nested into the response. Say your response is the following:

```
{
  "name":"John Doe",
  "age":11,
  "height":57,
  "address": {
    "postal": {
      "code":"11111",
      "region":"lc"
    },
  "city":"Tartu"
  }
}
```

You can get the value `code` with the following

```
use Habitue\Habitue;

/**
* @var $collected \Habitue\Integration\Collector
*/
$collected = \habitue('https://ninja.example/users')->get();

$collected->get('name'); //John Doe

$collected->getName(); // John Doe

$collected->getAddress() // Collection with {"postal": {"code":"11111","region":"lc"}, "city":"Tartu"}

    ->getPostal() // Collection with {"code":"11111","region":"lc"}

    ->getCode(); //11111
```

API Available
-------------

[](#api-available)

### Habitue class

[](#habitue-class)

```
Habitue::__construct(url: string, [data: array = [...]], [config: array = [...]])
Habitue::setHeaders(headers: array, [overwrite: bool = false]): HabitueInterface
Habitue::setBody(body: array, [overwrite: bool = false]): HabitueInterface
Habitue::get([key = null]): HabitueResponse.getReturn): Collector|mixed // Depends on the type of configuration at config: 'habitue.return'
Habitue::post([key = null]): Collector|mixed // Depends on the type of configuration at config: 'habitue.return'
Habitue::patch([key = null]): Collector|mixed // Depends on the type of configuration at config: 'habitue.return'
Habitue::put([key = null]): Collector|mixed // Depends on the type of configuration at config: 'habitue.return'
Habitue::delete([key = null]): Collector|mixed // Depends on the type of configuration at config: 'habitue.return'
Habitue::getResponse(): ClientResponse
Habitue::make(url: string, [data: array = [...]], [config: array = [...]]): HabitueInterface
```

### ClientResponse Class

[](#clientresponse-class)

```
ClientResponse::__construct(data: string, statusCode: int, headers: array)
ClientResponse::getData(): string
ClientResponse::getStatusCode(): int
ClientResponse::getHeaders(): array
ClientResponse::__toString(): string
```

Contributions
-------------

[](#contributions)

- Make a PR
- Make sure the tests passes
- It gets it approved
- It gets merged

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance41

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity72

Established project with proven stability

 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 ~152 days

Recently: every ~328 days

Total

13

Last Release

417d ago

Major Versions

v3.0-alpha → v4.0-alpha2020-03-29

v4.0-alpha → v5.0-alpha2020-03-31

1.0.0 → 2.0.02021-08-17

2.0.0 → v3.0.02025-03-22

v3.0.0 → v4.0.02025-03-22

PHP version history (3 changes)v1.0-alphaPHP &gt;=7.4

v3.0.0PHP &gt;=8.0

v4.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/364011bafbabff7b8c66b670b16ae372944dd4cc555531affffd901aae53d297?d=identicon)[omitobisam](/maintainers/omitobisam)

---

Top Contributors

[![omitobi](https://avatars.githubusercontent.com/u/16482234?v=4)](https://github.com/omitobi "omitobi (76 commits)")

---

Tags

http-clientlaravelphphttpjsonGuzzlecollectionharbitue

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/omitobisam-laravel-habitue/health.svg)

```
[![Health](https://phpackages.com/badges/omitobisam-laravel-habitue/health.svg)](https://phpackages.com/packages/omitobisam-laravel-habitue)
```

###  Alternatives

[graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

981.2M24](/packages/graze-guzzle-jsonrpc)[graham-campbell/guzzle-factory

Provides A Simple Guzzle Factory With Good Defaults

916.4M49](/packages/graham-campbell-guzzle-factory)

PHPackages © 2026

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