Download the PHP package zlob/php-json-server without Composer
On this page you can find all versions of the php package zlob/php-json-server. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zlob/php-json-server
More information about zlob/php-json-server
Files in zlob/php-json-server
Informations about the package php-json-server
PHP JSON Server
Easy to use library, that provides you REST API server in a few minutes. Created for front-end developers who need a quick back-end for prototyping. May be used with you lovely php web framework
Inspired by JSON Server
NOT FOR PRODUCTION
Install
via composer:
Example
You can use this library with any php web framework. Here is example how to integrate it with Laravel 5.1:
-
First, you need to create controller, where we will use php-json-server:
-
Then, add to routes.php file new route, to link '/api/*' route with our controller method handleRequest
-
Finaly, we can optionaly fill our database with some data. To do this, open php-json-server/db/db.json file and add some data:
- Thats all! Now, if you go to "/api/posts" you'll get { "id": 1, "title": "json-server", "author": "zlob" }
Based on the previous db.json file, here are all routes:
To filter resources
To slice resources, add _start
and _end
or _limit
(an X-Total-Count header is included in the response).
To sort resources, add _sort
and _order
(ascending order by default).
To make a full-text search on resources, add _query
.
To embed other resources, add _embed
(separate by ',' for more then one resources).
CLI: Generate random data
You can fill database with fake data in one command. In example, to create table posts, with 50 resources, that contains fields title, date, author and content, in jsonServer directory use command:
Where where fields separated by space, and field name, field type and additional parameter separated by '.' Field type and parameters described in faker, that used inside.
License
MIT - Zlob
All versions of php-json-server with dependencies
nikic/php-parser Version ~1.0
doctrine/inflector Version ^1.0
symfony/http-foundation Version 2.7.*
symfony/console Version 2.7.*
fzaninotto/faker Version 1.5.*