承接 yvesnda/simple_http 相关项目开发

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

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

yvesnda/simple_http

最新稳定版本:v1.0.0

Composer 安装命令:

composer require yvesnda/simple_http

包简介

README 文档

README

A simple PHP HTTP library with a single helper function for making HTTP requests.

Installation

Install via Composer:

composer require yvesnda/simple_http

Usage

The library provides a single function: http_request.

require 'vendor/autoload.php';

// Example GET request
$response = http_request('GET', 'https://api.example.com/data');

// Example POST request with JSON data
$response = http_request('POST', 'https://api.example.com/data', [], ['key' => 'value']);

// Access response details
if ($response['error']) {
    echo "Error: " . $response['error'];
} else {
    echo "HTTP Code: " . $response['code'] . PHP_EOL;
    print_r($response['result']);
}

Function Signature

http_request($method, $url, $headers = [], $data = '', $follow_response_type = 1)
  • $method: HTTP method (GET, POST, PUT, PATCH, DELETE)
  • $url: Request URL
  • $headers: (optional) Array of headers
  • $data: (optional) Array or string of data to send
  • $follow_response_type: (optional) If 1, tries to decode JSON/XML responses

Response Structure

The function returns an array with:

  • code: HTTP status code
  • headers: Request headers sent
  • raw: Raw response body
  • result: Parsed response (array for JSON, SimpleXMLElement for XML, or raw string)
  • error: Error message if any

License

MIT License. See LICENSE.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-07