Giter VIP home page Giter VIP logo

response's Introduction

项目概述

  • 基于Hyperf2.0中的Response扩展

运行环境

确保操作环境满足以下要求:

  • PHP >= 7.2
  • Swoole PHP extension >= 4.4,and Disabled Short Name
  • OpenSSL PHP extension
  • JSON PHP extension
  • PDO PHP extension (If you need to use MySQL Client)
  • Redis PHP extension (If you need to use Redis Client)
  • Protobuf PHP extension (If you need to use gRPC Server of Client)

安装

  • 引入组件
$ compsoer require "heartide/response"

使用

  • 文件
app/Controller/AbstractController.php
  • 删除
use Hyperf\HttpServer\Contract\ResponseInterface;

注入

use Heartide\Response\Response;
use Psr\Container\ContainerInterface;

    /**
     * @Inject
     * @var Response
     */
    protected $response;
  • 在任意类中extends AbstractController
   class IndexController extends AbstractController
   {
       public function index()
       {
           $data = [
                'order_id' => 1234 
            ];
           return $this->response->success($data);
       }
   }
  • 效果
{
  "code": 0,
  "data": {
    "order_id": 1234
  }
}

response's People

Contributors

heartides avatar skywalker0606 avatar

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.