定制 storinka/invoke 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

storinka/invoke

Composer 安装命令:

composer require storinka/invoke

包简介

Invoke Core library

README 文档

README

Invoke

PHP library for building fast and modern web APIs.

Installation

The library is still work-in-progress.

composer require storinka/invoke:^2 storinka/invoke-http:^2

Basic example

  1. Create index.php
use Invoke\Invoke;

function add(float $a, float $b): float
{
    return $a + $b;
}

Invoke::create([
    "add"
])->serve();
  1. Run a server
php -S localhost:8000 index.php 
  1. Make a request
curl 'localhost:8000/add?a=2&b=2'

# { "result": 4 }

Complex example

  1. Create a type
use Invoke\Data;

class UserResult extends Data
{
    public int $id;
    
    public string $name;
}
  1. Create a method to get list of users
use Invoke\Method;

class GetUsers extends Method
{
    protected function handle(int $page, int $perPage): array
    {
        $usersFromDB = getUsersFromDb($page, $perPage);
        
        return UserResult::many($usersFromDB);
    }
}
  1. Setup Invoke
use Invoke\Invoke;

Invoke::create([
    "getUsers" => GetUsers::class
])->serve();
  1. Run a server and try to invoke:
curl 'localhost:8000/getUsers?page=1&perPage=10'

# { "result": [ ... ] }

统计信息

  • 总下载量: 1.8k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-02-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固