承接 kingsoft/http 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

kingsoft/http

最新稳定版本:3.8.3

Composer 安装命令:

composer require kingsoft/http

包简介

Http Request/Response handler. It's a simple and easy to use library to handle http request and response.

README 文档

README

HTTP request, response, statuscodes

sample implementation

Sample implementation of the abstract Rest class under sample. Here a possible implementation:

use Kingsoft\Http\StatusCode;
use Kingsoft\PersistRest\PersistRest;
use Kingsoft\PersistRest\PersistRequest;
use Kingsoft\Http\Response;

class MyRest extends Rest
{
  public function get(): {
    Response::sendStatusCode( StatusCode::OK );
    Response::sendPayload( [ 'result'=> 'ok']);
  }
  public function post(): {
    Response::sendStatusCode( StatusCode::OK );
    Response::sendPayload( [ 'result'=> 'ok']);
  }
}

try {
  $request = new Request(
    [ 'Test' ],                         // allowed endpoints
                                        // when using persist-db discover.php the result will give you a plugin list.
    "GET, POST",                        // allowed methods, (might change to a string array in the future)
    "http://client.example.com",        // allowed origin
  );

  $request->setLogger( LOG );           // add a (monolog) logger
  $api = new MyRest( $request, LOG );   // create the request handler
  $api->handleRequest();                // handle the request, which will send a well-formed HATEOAS response
} catch ( Exception $e ) {              // If things go terribly wrong, send an error to the client
  Response::sendError( $e->getMessage(), StatusCode::InternalServerError );
                                        // By this time one or more errors have been logged already.
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固