PHPackages                             caoym/phprs-restful - 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. [Database &amp; ORM](/categories/database)
4. /
5. caoym/phprs-restful

ActiveLibrary[Database &amp; ORM](/categories/database)

caoym/phprs-restful
===================

PHP RESTful API framework.

v2.1.1(7y ago)64995131[3 PRs](https://github.com/caoym/phprs-restful/pulls)MITPHPPHP &gt;=5.5.9CI failing

Since Jan 20Pushed 4y ago76 watchersCompare

[ Source](https://github.com/caoym/phprs-restful)[ Packagist](https://packagist.org/packages/caoym/phprs-restful)[ RSS](/packages/caoym-phprs-restful/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (22)Used By (0)

PhpBoot
=======

[](#phpboot)

[![GitHub license](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://raw.githubusercontent.com/caoym/phpboot/master/LICENSE)[![Package version](https://camo.githubusercontent.com/7cceca17fbe5391313480b2d42d6a9c2d8db8798b42c8b53d716b8da619cd6e3/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63616f796d2f706870626f6f742e737667)](https://packagist.org/packages/caoym/phpboot)[![Documentation Status](https://camo.githubusercontent.com/38dc7850c011dcdcf22a5d4687d239367c1f648be5c8196bfd6a9fffd0ed0ac8/68747470733a2f2f72656164746865646f63732e6f72672f70726f6a656374732f706870626f6f742f62616467652f3f76657273696f6e3d6c6174657374)](http://phpboot.readthedocs.io/zh/latest/?badge=latest)[![Build Status](https://camo.githubusercontent.com/a7eca93999d34b2c394422ca5c6827a4037b5767e17eb64665a1a88eae9b8a94/68747470733a2f2f7472617669732d63692e6f72672f63616f796d2f706870626f6f742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/caoym/phpboot)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/eb3b9240fd511f4b6d3168072d5f9f000002452c12c6fc75256393fa1891baec/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f63616f796d2f706870626f6f742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/caoym/phpboot/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/9cfadd55eeaf717469246f95a4c0da7ba7e1681806c7c44e05f89a71151c27f7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f63616f796d2f706870626f6f742f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/caoym/phpboot/?branch=master)

> phprs-restful 2.x is renamed to PhpBoot, and incompatible with 1.x. You can get the old version from [phprs-restful v1.x](https://github.com/caoym/phprs-restful/tree/v1.2.4)

[查看中文说明](https://github.com/caoym/phpboot/blob/master/README.zh.md)

**[PhpBoot](https://github.com/caoym/phpboot)** is an easy and powerful PHP framework for building RESTful/Microservices APIs.

Specialities
------------

[](#specialities)

PhpBoot provides mainstream features, such as IOC, HOOK, ORM, Validation, etc. But the most striking features are:

### 1. Designing object-oriented APIs

[](#1-designing-object-oriented-apis)

**WITHOUT** PhpBoot:

```
class BookController
{
    public function findBooks(Request $request)
    {
        $name = $request->get('name');
        $offset = $request->get('offset', 0);
        $limit = $request->get('limit', 10);
        ...
        return new Response(['total'=>$total, 'data'=>$books]);
    }

    public function createBook(Request $request)
    ...
}
```

**WITH** PhpBoot:

```
/**
 * @path /books/
 */
class Books
{
    /**
     * @route GET /
     * @return Book[]
     */
    public function findBooks($name, &$total=null, $offset=0, $limit=10)
    {
        $total = ...
        ...
        return $books;
    }

    /**
     * @route POST /
     * @param Book $book {@bind request.request} bind $book with http body
     * @return string id of created book
     */
    public function createBook(Book $book)
    {
        $id = ...
        return $id;
    }
}
```

Read more: [phpboot-example](https://github.com/caoym/phpboot-example)。

### 2. Swagger

[](#2-swagger)

PhpBoot can automatically generate Swagger JSON，which can be rendered as document by Swagger UI like this：

[![](https://github.com/caoym/phpboot/raw/master/docs/_static/WX20170809-184015.png)](https://github.com/caoym/phpboot/raw/master/docs/_static/WX20170809-184015.png)

Read more: [Online Demo](http://swagger.phpboot.org/?url=http://example.phpboot.org/docs/swagger.json)

### 3. RPC

[](#3-rpc)

Call the remote Books with RPC:

```
$books = $app->make(RpcProxy::class, [
        'interface'=>Books::class,
        'prefix'=>'http://x.x.x.x/'
    ]);

$books->findBooks(...);
```

Concurrent call RPC：

```
$res = MultiRpc::run([
    function()use($service1){
        return $service1->doSomething();
    },
    function()use($service2){
        return $service2->doSomething();
    },
]);
```

Read more: [RPC](http://phpboot.org/zh/latest/advanced/rpc.html)

### 4. IDE friendly

[](#4-ide-friendly)

[![](https://github.com/caoym/phpboot/raw/master/docs/_static/db.gif)](https://github.com/caoym/phpboot/raw/master/docs/_static/db.gif)

Features
--------

[](#features)

- [Route](http://phpboot.org/zh/latest/basic/route.html)
- [Parameters binding ](http://phpboot.org/zh/latest/basic/params-bind.html)
- [Validation](http://phpboot.org/zh/latest/basic/validation.html)
- [Dependency Injection(IOC)](http://phpboot.org/zh/latest/basic/di.html)
- [DB](http://phpboot.org/zh/latest/basic/db.html)
- [ORM](http://phpboot.org/zh/latest/advanced/orm.html)
- [Docgen(Swagger)](http://phpboot.org/zh/latest/advanced/docgen.html)
- [RPC](http://phpboot.org/zh/latest/advanced/rpc.html)
- [Hook](http://phpboot.org/zh/latest/advanced/hook.html)
- [CLI](http://phpboot.org/zh/latest/advanced/cli.html)

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

[](#installation)

1. Install composer

    ```
    curl -s http://getcomposer.org/installer | php

    ```
2. Install PhpBoot

    ```
    composer require "caoym/phpboot"

    ```
3. index.php

    ```
