sw-fw-less
  • sw-fw-less
  • get started
    • Installation
    • Directory
    • Config
    • Quick Start
  • MVC
    • Router
    • Middleware
    • Request
    • Param Validator
    • Model
    • Response
  • Database
    • MySQL
    • Redis
    • Elasticsearch
  • Storage
    • General
    • File
    • Qiniu
    • Alioss
  • OTHER
    • Pagination
    • Helper
    • Error Handler
    • AMQP-0-9-1
    • Events
  • Deployment
    • Nginx
    • Docker
  • APPENDIX
    • Development Rules
Powered by GitBook
On this page

Was this helpful?

  1. MVC

Response

Example

// Response plain text with status code 200
\App\components\Response::output('ok');

// Response plain text with status code 500
\App\components\Response::output('fail', 500);

// Response json with status code 200
\App\components\Response::json(['foo' => 'bar']);
\App\components\Response::json('{"foo": "bar"}');

// Response json with status code 500
\App\components\Response::json(['foo' => 'bar'], 500);
\App\components\Response::json('{"foo": "bar"}', 500);

// Response plain text with status code 200 and headers
\App\components\Response::output('ok', 200, ['X-UUID' => 123456]);

// Response json with status code 200 and headers
\App\components\Response::json(['foo' => 'bar'], 200, ['X-UUID' => 123456]);
\App\components\Response::json('{"foo": "bar"}', 200, ['X-UUID' => 123456]);
PreviousModelNextMySQL

Last updated 6 years ago

Was this helpful?