lablnet/http-client
Composer 安装命令:
composer require lablnet/http-client
包简介
PHP http client package.
README 文档
README
http-client is the php package. It provides the ability to manage and parse request object. It also provides support for HTTP client transactions via cURL.
Requirement
- PHP
- Composer
install
run this command
composer require lablnet/http-client
BASIC USAGE
The request object, GET example
Let's use a GET request with the URL '/index.php?var=value'
<?php require '../vendor/autoload.php'; $request = new Lablnet\Request(); // Get the value of _GET['var'] $var = $request->getQuery('var'); //it print the get request var_dump($var);
The request object, POST example
Let's use a POST request.
// Get the value of $_POST['id'] if ($request->isPost()) { $id = $request->getPost('id'); }
Creating a response object
//Response $config = [ 'code' => 200, 'headers' => [ 'Content-Type' => 'text/html' ] ]; $response = new Lablnet\Response($config); $response->setBody('This is a plain text file.'); $response->send();
Simple response redirect
//Redirect to other page/site. (new Lablnet\Redirect('https://zestframework.xyz/'));
Using the cURL client
//Using the cURL client //Send request to https://zestframework.xyz login page with post method $request = $request->curl("https://zestframework.xyz/account/login/action","POST"); //Set transfer and return header $request->setReturnHeader(true)->setReturnTransfer(true); //Set the fields $request->setFields([ 'username' => 'your-username', 'password' => 'your-password' ]); //Send the request $request->send(); // return => 200 $statusCode = $request->getCode(); // Display the body of the returned response echo "<br\>".$request->getBody();
lablnet/http-client 适用场景与选型建议
lablnet/http-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 258 次下载、GitHub Stars 达 11, 最近一次更新时间为 2019 年 01 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「package」 「php」 「http」 「free」 「psr-7」 「Lablnet」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 lablnet/http-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lablnet/http-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 lablnet/http-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Simple ASCII output of array data
http客户端
Easily add Excepct-CT header to your project
Build mini web servers in PHP for testing
统计信息
- 总下载量: 258
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 17
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-01-24