GithubHelp home page GithubHelp logo

caoym / phpboot Goto Github PK

View Code? Open in Web Editor NEW
659.0 76.0 175.0 1.16 MB

:coffee: 🚀 tiny & fast PHP framework for building Microservices/RESTful APIs, with useful features: IOC, Hook, ORM, RPC, Swagger, Annotation, Parameters binding, Validation, etc.

Home Page: http://phpboot.org

License: MIT License

PHP 100.00%
swagger orm rpc annotation restful microservices framework

phpboot's Introduction

PhpBoot

GitHub license Package version Documentation Status Build Status Scrutinizer Code Quality Code Coverage

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.

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;
    }
}

Read more: phpboot-example。    

2. Swagger

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

Read more: Online Demo

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

Features

Installation

  1. Install composer

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

    composer require "caoym/phpboot"
    
  3. index.php

    <?php
    require __DIR__.'/vendor/autoload.php';
    
    $app = \PhpBoot\Application::createByDefault(__DIR__.'/config/config.php');
    $app->loadRoutesFromPath(__DIR__.'/App/Controllers');
    $app->dispatch();

Help & Documentation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.