PHPackages                             sawarame/php-json-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. sawarame/php-json-server

ActiveProject[API Development](/categories/api)

sawarame/php-json-server
========================

REST API that can use JSON format files.

V0.3.2(5y ago)646[1 issues](https://github.com/sawarame/php-json-server/issues)[1 PRs](https://github.com/sawarame/php-json-server/pulls)BSD-3-ClausePHPPHP ^7.3CI failing

Since May 4Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/sawarame/php-json-server)[ Packagist](https://packagist.org/packages/sawarame/php-json-server)[ RSS](/packages/sawarame-php-json-server/feed)WikiDiscussions master Synced today

READMEChangelog (9)Dependencies (9)Versions (12)Used By (0)

php-json-sever
==============

[](#php-json-sever)

[![Build Status](https://github.com/sawarame/php-json-server/workflows/build/badge.svg?branch=master)](https://github.com/sawarame/php-json-server/actions?query=workflow%3Abuild+branch%3Amaster)[![Version](https://camo.githubusercontent.com/c1bb74a9df75abee737abefc6aaf04a960e109cd1a8dd7a488effcc380768e0a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7361776172616d652f7068702d6a736f6e2d7365727665722e7376673f7374796c653d666c6174)](https://packagist.org/packages/sawarame/php-json-server)

`php-json-server` is RESTful API with PHP. The data can be wrote json format, and you can easily set up RESTful API mock server.

Installation and Startup
------------------------

[](#installation-and-startup)

Use [Composer](https://getcomposer.org/) for installation and server start-up.

```
# install
$ composer create-project sawarame/php-json-server path/to/install
```

Once installed, You can startup `php-json-server` with PHP build-in server.

```
# Startup with PHP build-in server
$ cd path/to/install
$ composer run --timeout 0 serve
```

Then visit the site at . If the welcome page is displayed, installation and startup are successful.

Prepare data
------------

[](#prepare-data)

Save data file in the path below.

```
path/to/install/data/db/schema_name.json

```

The `schema_name` of file name is used to data name. The data name can be any name, and multiple datas can be saved under different name. There is a `sample.json` in the initial state.

```
[
    {
        "id": 1,
        "name": "Red",
        "code": "#ff0000"
    },
    {
        "id": 2,
        "name": "Green",
        "code": "#00ff00"
    },
    {
        "id": 3,
        "name": "Blue",
        "code": "#0000ff"
    }
]
```

Data must wrote by array of json format. Data structure is arbitrary, but `id` column is required.

Read data
---------

[](#read-data)

To get the data named `schema_name`, access below URL with GET method.

```
$ curl -X GET 'http://localhost:8080/schema_name'
```

Default data rows per page is 20. if you want to change it, use `rows` parameter.

```
$ curl -X GET 'http://localhost:8080/schema_name?rows=10'
```

How to change page is use `page` parameter.

```
$ curl -X GET 'http://localhost:8080/schema_name?page=2'
```

You can search by using the column name as the parameter.

```
$ curl -X GET 'http://localhost:8080/schema_name?name=Green'
```

Normally, When multiple parameters are specified, the search will be an AND condition. If you want to search with OR condition, use `or` to `search_type` parameter.

```
$ curl -X GET 'http://localhost:8080/sample?name[]=Red&name[]=Green&search_type=or'
```

### Response header

[](#response-header)

The response header contains information about paging.

namedescriptionPJS-Total:Total number of datas.PJS-pages:Total number of pages.PJS-Rows:Rows of current page.Find row
--------

[](#find-row)

Example below receive the data that `id` column value is 123.

```
$ curl -X GET 'http://localhost:8080/schema_name/123'
```

Insert row
----------

[](#insert-row)

Use POST method for insert data.

```
$ curl -X POST 'http://localhost:8080/schema_name' \
  -H 'Content-Type: application/json' \
  --data-raw '{"name":"Gray","code":"#808080"}'
```

Created data will be returned.

```
{"id":4,"name":"Gray","code":"#808080"}
```

Update row
----------

[](#update-row)

Use PUT method for update data.

```
$ curl -X PUT 'http://localhost:8080/schema_name/2' \
  -H 'Content-Type: application/json' \
  --data-raw '{"name":"Yellow","code":"#FFFF00"}'
```

Updated data will be returned.

```
{"id":2,"name":"Yellow","code":"#FFFF00"}
```

Delete row
----------

[](#delete-row)

Use DELETE method for delete data.

```
$ curl -X DELETE 'http://localhost:8080/schema_name/4'
```

Deleted data will be returned.

```
{"id":4,"name":"Gray","code":"#808080"}
```

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance46

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Recently: every ~70 days

Total

9

Last Release

1965d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4434225?v=4)[鰆目 靖士](/maintainers/sawarame)[@sawarame](https://github.com/sawarame)

---

Top Contributors

[![sawarame](https://avatars.githubusercontent.com/u/4434225?v=4)](https://github.com/sawarame "sawarame (83 commits)")

---

Tags

jsonapilaminasrestful

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/sawarame-php-json-server/health.svg)

```
[![Health](https://phpackages.com/badges/sawarame-php-json-server/health.svg)](https://phpackages.com/packages/sawarame-php-json-server)
```

###  Alternatives

[obiefy/api-response

Simple Laravel package to return Json responses.

17325.0k](/packages/obiefy-api-response)[walle89/swedbank-json

Unofficial API client for the Swedbank's and Sparbanken's mobile apps in Sweden.

782.5k](/packages/walle89-swedbank-json)[wayofdev/laravel-symfony-serializer

📦 Laravel wrapper around Symfony Serializer.

2117.7k](/packages/wayofdev-laravel-symfony-serializer)

PHPackages © 2026

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