output->set_content_type('application/json'); } // 访问:GET /api/v1/user/center public function center() { $data = [ 'code' => 200, 'version' => 'v1', 'data' => [ 'username' => 'John Doe', 'email' => 'john@example.com' ] ]; $this->output->set_output(json_encode($data)); } // 访问:POST /api/v1/user/login public function login() { // 从输入流获取JSON数据 $input = json_decode(file_get_contents('php://input'), true); // 业务逻辑... } }