PHPackages                             bear/stub-json - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. bear/stub-json

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bear/stub-json
==============

Fake BEAR.Resource responses with JSON files

0.1.0(4mo ago)40MITPHPPHP ^8.1

Since Jan 7Pushed 4mo ago2 watchersCompare

[ Source](https://github.com/bearsunday/BEAR.FakeJson)[ Packagist](https://packagist.org/packages/bear/stub-json)[ RSS](/packages/bear-stub-json/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (4)Used By (0)

BEAR.FakeJson
=============

[](#bearfakejson)

Fake BEAR.Resource responses with JSON files for frontend development.

Overview
--------

[](#overview)

This module allows frontend development to proceed before backend implementation is complete by faking resource responses with JSON files. It only supports happy path scenarios - for error handling and edge cases, use the actual backend implementation.

Benefits
--------

[](#benefits)

- Develop frontend HTML templates without waiting for backend
- Preview final output with realistic data
- Enable parallel frontend/backend development
- Use JSON as a shared contract between teams

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

[](#installation)

```
composer require bear/fake-json
```

Module Setup
------------

[](#module-setup)

Create a `FakeModule` for the fake context:

```
// src/Module/FakeModule.php
namespace MyVendor\MyApp\Module;

use BEAR\FakeJson\FakeJsonModule;
use Ray\Di\AbstractModule;

class FakeModule extends AbstractModule
{
    protected function configure(): void
    {
        $this->install(new FakeJsonModule(__DIR__ . '/../../var/fake'));
    }
}
```

Then use the `fake-app` context to enable fake responses:

```
php bin/page.php get /
# Uses actual backend

php -d "BEAR_CONTEXTS=fake-app" bin/page.php get /
# Uses JSON files from var/fake/
```

Usage
-----

[](#usage)

Create JSON files matching your resource structure:

```
var/fake/Page/Index.json
var/fake/App/User.json

```

Example `var/fake/Page/Index.json`:

```
{
    "greeting": "Hello",
    "user": {
        "name": "John"
    }
}
```

When the resource method is called, the JSON content is returned as the resource body instead of executing the actual method. If no JSON file exists, the original method executes normally.

Best Practices
--------------

[](#best-practices)

- Install only in development context, not in production
- Keep JSON structure synchronized with actual resource output
- Use realistic data that matches production scenarios
- Version control JSON files as a contract between frontend and backend teams

Limitations
-----------

[](#limitations)

- Happy path only - does not support error responses (4xx, 5xx)
- Does not set response headers or status codes
- JSON files must be valid JSON objects (not arrays)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance76

Regular maintenance activity

Popularity4

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 82.4% 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

Unknown

Total

1

Last Release

131d ago

### Community

Maintainers

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

---

Top Contributors

[![koriym](https://avatars.githubusercontent.com/u/529021?v=4)](https://github.com/koriym "koriym (14 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bear-stub-json/health.svg)

```
[![Health](https://phpackages.com/badges/bear-stub-json/health.svg)](https://phpackages.com/packages/bear-stub-json)
```

PHPackages © 2026

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