PHPackages                             dbt/client-fake - 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. dbt/client-fake

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

dbt/client-fake
===============

Easily fake Laravel's HTTP Client

2.0.0(3y ago)01.5k↓100%MITPHPPHP &gt;=8.1

Since Mar 27Pushed 3y ago1 watchersCompare

[ Source](https://github.com/DeBoerTool/client-fake)[ Packagist](https://packagist.org/packages/dbt/client-fake)[ Docs](https://github.com/dbt/client-fake)[ RSS](/packages/dbt-client-fake/feed)WikiDiscussions trunk Synced 1mo ago

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

Client Fake for Laravel
=======================

[](#client-fake-for-laravel)

This package provides an easy way to fake HTTP calls for services that requires Laravel's HTTP Client in testing contexts. If you're using the HTTP Facade, this package isn't for you.

Simply extend or directly construct the `ClientFake`, register your fakes, then commit or invoke the result. When your service resolves the HTTP Client from the container, it will be resolved with the fakes applied only to that instance of the HTTP Client.

For instance if you have `FooService` and `BarService`, if you register a fake for `BarService`, the fake only be applied to that service, and not to any others.

This is useful when you have one service that you want to fake, but not others.

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

[](#installation)

You can install the package via composer:

```
composer require dbt/client-fake --dev
```

Usage
-----

[](#usage)

You can use the `ClientFake` class directly, or extend it and define method fakes of your own.

If you want to use the `ClientFake` directly, you can do so like this (for example, in the body of your test):

```
use Dbt\ClientFake\ClientFake;
use Dbt\ClientFake\Options\Options;

$clientFake = new ClientFake($app, new Options(
    service: MyService::class,
    base: 'https://my-service.com',
    // Or false if the API isn't versioned.
    version: 'v1',
    // Optional headers to add to all fake responses for use in testing.
    headers: ['X-My-Header' => 'some value'],
));

$clientFake->fake('my/endpoint', ['data' => 'some data']);

$clientFake->commit();
// or
$clientFake();
```

Then you can resolve your service and use it as normal:

```
$service = resolve(MyService::class);

$response = $service->callMyEndpoint();

$this->assertSame(['data' => 'some data'], $response->json());
$this->assertSame('some value', $response->header('X-My-Header'));
```

### Catchall

[](#catchall)

By default, a catchall is added, which will return a 500 response for any endpoint that isn't faked. You can disable this:

```
$clientFake->withoutCatchall();
```

### Conditionally Enabling

[](#conditionally-enabling)

You can conditionally enable and disable the fake by using the `enable` method:

```
$clientFake->enable($booleanCondition);
```

You can optionally add a callback that will be resolved from the container and executed when the boolean condition is false:

```
$clientFake->enable($booleanCondition, function (SomeOtherService $service) {
    $service->doSomething();
});
```

### Options

[](#options)

You can use the `ClientFakeOptions` object as-is, or define your own by implementing the `ClientFakeOptionsInterface`.

Etc.
----

[](#etc)

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

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Total

8

Last Release

1136d ago

Major Versions

1.1.4 → 2.0.02023-03-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/ebd3fe214b5768e700ae43c7fdc4b83d249972a6a97a0faef372d0ec19256eca?d=identicon)[danielsdeboer](/maintainers/danielsdeboer)

---

Top Contributors

[![danielsdeboer](https://avatars.githubusercontent.com/u/13170241?v=4)](https://github.com/danielsdeboer "danielsdeboer (42 commits)")

---

Tags

httpphplaraveldbt

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/dbt-client-fake/health.svg)

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

###  Alternatives

[omniphx/forrest

A Laravel library for Salesforce

2724.4M8](/packages/omniphx-forrest)[dragon-code/laravel-http-logger

Logging incoming HTTP requests

319.8k3](/packages/dragon-code-laravel-http-logger)[sockeon/sockeon

Framework-agnostic PHP WebSocket and HTTP server library with attribute-based routing and support for namespaces and rooms.

291.3k2](/packages/sockeon-sockeon)[laragear/api-manager

Manage multiple REST servers to make requests in few lines and fluently.

161.8k](/packages/laragear-api-manager)

PHPackages © 2026

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