PHPackages                             satahippy/fake-api-server - 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. [API Development](/categories/api)
4. /
5. satahippy/fake-api-server

ActiveLibrary[API Development](/categories/api)

satahippy/fake-api-server
=========================

Fake your API. Primarily for frontend development.

v0.1.1(10y ago)0281MITPHPPHP &gt;=5.5.0

Since Sep 6Pushed 10y ago1 watchersCompare

[ Source](https://github.com/satahippy/fake-api-server)[ Packagist](https://packagist.org/packages/satahippy/fake-api-server)[ RSS](/packages/satahippy-fake-api-server/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (3)Used By (1)

Fake API Server
===============

[](#fake-api-server)

Usage
-----

[](#usage)

All that you need is ... Data Provider! It's provide a data depend on a request

Data Providers
--------------

[](#data-providers)

Each Data Provider implements interface `Sata\FakeServerApi\DataProvider\IDataProvider`Now there is only one method `data` that receive `Psr\Http\Message\ServerRequestInterface` and returns some data

### RouterDataProvider

[](#routerdataprovider)

It's an compose data provider. That retrieves routes with data providers It uses [nikic/FastRoute](https://github.com/nikic/FastRoute) under the hood, so every route should meet the requirements.

#### Example

[](#example)

```
$provider = new RouterDataProvider([
    // limit and offset parameters only make sense
    '/local/articles[/]' => new PathDataProvider($filesystem, ['limit', 'offset']),
    // all other local data get from local data folder
    '/local/{trail:.*}' => new PathDataProvider($filesystem),
    // all r get from reddit (try request /r/PHP/hot.json)
    // requested every time cause of VoidCache
    '/r/{stub:.*}.json' => new ProxyDataProvider($redditGuzzle, $voidCache),
    // all r get from reddit (try request /get?your=paramter)
    '/get{stub:.*}' => new ProxyDataProvider($httpbinGuzzle, $cache),
    // all r get from reddit (try request /post?your=paramter with POST)
    '/post{stub:.*}' => new ProxyDataProvider($httpbinGuzzle, $cache)
]);

$data = $provider->data($request);
```

#### Features

[](#features)

After request satisfy the route, new instance of a request (with matched parameters) pass to the target data provider.

### FileDataProvider

[](#filedataprovider)

Just returns content of specified file.

#### Example

[](#example-1)

```
$provider = new FileDataProvider($filesystem, 'path/to/the/file.json');
$data = $provider->data($request);
```

#### Features

[](#features-1)

It's receives an instance of `League\Flysystem\Filesystem`. About Flysystem read more here - [thephpleague/flysystem](https://github.com/thephpleague/flysystem).

### PathDataProvider

[](#pathdataprovider)

Like a `FileDataProvider` it's returns a file content, but with some additional bahavior.

First of it's mount some folder (via Flysystem) to the request (or a visa versa). Also it can handle significant parameters.

#### Example

[](#example-2)

For example, if you have an posts API, you can mount `data/posts/` folder to all `/posts` requests. And of course, your API has a pagination logic. Like a `/posts?page=1`, `/posts?page=2`.

So by here is map of your request to the files

- `/posts` -&gt; `data/posts/default.json`
- `/posts?page=1` -&gt; `data/posts/page_1.json`
- `/posts?page=2` -&gt; `data/posts/page_2.json`
- `/posts?some=parameter` -&gt; `data/posts/default.json`

By default, if the file is not found the default file will be mounted.

```
$filesystem = new Filesystem(new Local(__DIR__ . '/data'));
$provider = new PathDataProvider($filesystem, ['page']);
$data = $provider->data($request);
```

### ProxyDataProvider

[](#proxydataprovider)

Primarily this data provider used for a slow connections.

It's receives an instances of [Guzzle Client](https://github.com/guzzle/guzzle) and [Doctrine Cache](https://github.com/doctrine/cache)

So every request will be proxied to the remote server and saved in cache.

#### Example

[](#example-3)

```
$cache = new FilesystemCache(__DIR__ . '/cache');
$voidCache = new VoidCache();
$filesystem = new Filesystem(new Local(__DIR__ . '/data'));
$redditGuzzle = new GuzzleHttp\Client(['base_uri' => 'https://www.reddit.com']);
$httpbinGuzzle = new GuzzleHttp\Client(['base_uri' => 'http://httpbin.org']);

// request everytime cause of VoidCache
$redditProvider = new ProxyDataProvider($redditGuzzle, $voidCache);
// request only once an save to the FilesystemCache
$httpbinProvider = new ProxyDataProvider($httpbinGuzzle, $cache);
```

Restrictions
------------

[](#restrictions)

There are really bad work with other response/request parameters. If your application relies on http statuses, so it's may be a huge problem.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

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

2

Last Release

3907d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ab1be8e8b248b044a9105795c938b57ae4a51b7cb35a746401bf21f7df0dfab?d=identicon)[sata](/maintainers/sata)

---

Top Contributors

[![satahippy](https://avatars.githubusercontent.com/u/5000502?v=4)](https://github.com/satahippy "satahippy (23 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/satahippy-fake-api-server/health.svg)

```
[![Health](https://phpackages.com/badges/satahippy-fake-api-server/health.svg)](https://phpackages.com/packages/satahippy-fake-api-server)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[saloonphp/saloon

Build beautiful API integrations and SDKs with Saloon

2.4k9.6M468](/packages/saloonphp-saloon)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[flat3/lodata

OData v4.01 Producer for Laravel

96320.9k](/packages/flat3-lodata)

PHPackages © 2026

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