定制 hraw/httpclient 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

hraw/httpclient

最新稳定版本:v1.0.0

Composer 安装命令:

composer require hraw/httpclient

包简介

A simple and easy to implement wrapper for PHP cURL

README 文档

README

A simple and easy to implement wrapper for PHP cURL.

Requirements

  • PHP 7.0 or higher
  • Composer for installation

Supported Methods:

  • GET
  • POST
  • PUT
  • PATCH
  • DELETE

Installation

composer require hraw/httpclient

Implementation

<?php

use Curl\HttpClient;

$response = HttpClient::get('https://jsonplaceholder.typicode.com/todos')->send();

In response, it returns the instance of CurlResponse class.

<?php

//Get the data returned by api
$response->data();

//Get status code
$response->statusCode();

//Check if response received is success response or not
$response->success();

//Get all the properties returned in response
$response->properties();

You can also add headers and timeout value while doing the curl request

HttpClient::get($url)
            ->timeout(60)
            ->headers([
                'Content-Type : application/json',
                'Authorization : Bearer {token}'
            ])
            ->send();

POST Request

HttpClient::post($url, $data)->send();
  • PUT and PATCH method has same implementations as POST method.
  • DELETE method has same implementation as GET method.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-10-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固