phprs-restful 2.x is renamed to PhpBoot, and incompatible with 1.x. You can get the old version from phprs-restful v1.x
PhpBoot is an easy and powerful PHP framework for building RESTful/Microservices APIs.
PhpBoot provides mainstream features, such as IOC, HOOK, ORM, Validation, etc. But the most striking features are:
WITHOUT PhpBoot:
class BookController
{
publicfunctionfindBooks(Request$request)
{
$name = $request->get('name');
$offset = $request->get('offset', 0);
$limit = $request->get('limit', 10);
...returnnewResponse(['total'=>$total, 'data'=>$books]);
}
publicfunction createBook(Request$request)
...
}WITH PhpBoot:
/** * @path /books/ */class Books
{
/** * @route GET / * @return Book[] */publicfunctionfindBooks($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 */publicfunctioncreateBook(Book$book)
{
$id = ... return $id;
}
}Read more: phpboot-example。
PhpBoot can automatically generate Swagger JSON,which can be rendered as document by Swagger UI like this:
Read more: Online Demo
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
Install composer
curl -s http://getcomposer.org/installer | phpInstall PhpBoot
composer require "caoym/phpboot"index.php
<?phprequire__DIR__.'/vendor/autoload.php'; $app = \PhpBoot\Application::createByDefault(__DIR__.'/config/config.php'); $app->loadRoutesFromPath(__DIR__.'/App/Controllers'); $app->dispatch();



