专为api开发的php框架,PhpBoot:专为开发 RESTful API 设计的 PHP 框架

PhpBoot

68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63616f796d2f706870626f6f742e73766768747470733a2f2f72656164746865646f63732e6f72672f70726f6a656374732f706870626f6f742f62616467652f3f76657273696f6e3d6c617465737468747470733a2f2f7472617669732d63692e6f72672f63616f796d2f706870626f6f742e7376673f6272616e63683d6d617374657268747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f63616f796d2f706870626f6f742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d617374657268747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f63616f796d2f706870626f6f742f6261646765732f636f7665726167652e706e673f623d6d6173746572

phprs-restful 2.x is renamed to PhpBoot, and incompatible with 1.x. You can get the old version from phprs-restful v1.x

Specialities

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

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;

}

}

2. Swagger

PhpBoot can automatically generate Swagger JSON,which can be rendered as document by Swagger UI like this:

982525ae7e5c57a87d2153473fa0d8ab.png

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

4. IDE friendly

db.gif

Features

Installation

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

Install PhpBoot composer require "caoym/phpboot"

index.php

require __DIR__.'/vendor/autoload.php';

$app = \PhpBoot\Application::createByDefault(__DIR__.'/config/config.php');

$app->loadRoutesFromPath(__DIR__.'/App/Controllers');

$app->dispatch();

Help & Documentation

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值