thevenrex/curlx
Composer 安装命令:
composer require thevenrex/curlx
包简介
HTTP basic library written in PHP
README 文档
README
CurlX is an HTTP basic library written in PHP for human beings and has no dependencies, working with PHP 8.2+.
CurlX allows you to send GET, POST, PUT, DELETE AND MORE HTTP METHODS. You can add headers, form data, json data, and parameters with simple arrays, and access the response data in the same way. You can add an HTTP TUNNEL with PROXY, server ROTATIONS like LUMINATI, APIFY, IPVANISH.
GET, POST AND CUSTOM Syntax
# GET $CurlX->get("https://api.myip.com/"); # POST $CurlX->post("https://api.myip.com/", "my_form_id=test&hello=mom"); # CUSTOM $CurlX->custom("https://api.myip.com/", "HEAD"); $CurlX->run();
HTTP TUNNEL SYNTAX
# PROXY (http/s, socks4, socks5) $server = [ "method" => "tunnel", "server" => "47.254.145.99:3128" ]; # LIMINATI valid syntax example $session => mt_rand(); $server = [ "method" => "custom", "server" = "http://zproxy.lum-superproxy.io:22225", "auth" => "lum-customer-hl_876f552a-zone-static-route_err-pass_dyn-country-RU-session-$session:my_ultra_secret_password" ]; # APIFY valid syntax example $server = [ "method" => "custom", "server" = "http://proxy.apify.com:8000", "auth" => "auto:my_ultra_secret_password" ]; # IPVANISH valid syntax example $server = [ "method" => "CUSTOM", "server" => "akl-c12.ipvanish.com:1080", "auth" => "my_zone_customer_id:my_zone_customer_password" ];
GET SYNTAX
# Simple GET $test0 = $CurlX->get("http://httpbin.org/get"); # GET with Custom Headers $headers = array( "Host: api.myip.com", "my-custom-header: my-header-value" ); $test1 = $CurlX->get("http://httpbin.org/get", $headers); # GET with Headers and Cookie File $cookie = uniqid(); $test2 = $CurlX->get("http://httpbin.org/get", $headers, $cookie); #GET with Headers, Cookie and Proxy Tunnel $server = [ "method" => "tunnel", "server" => "47.254.145.99:3128" ]; $test3 = $CurlX->get("http://httpbin.org/get", $headers, $cookie, $server); # After all requests were complete, you can delete the cookie file, Only when you use the $cookie parameter. $CurlX->deleteCookie(); # Response status of the request var_dump($test3->isSuccess()); // bool(true) # Status code of the request var_dump($test3->getStatusCode()); // int(200) # Content type of the request var_dump($test3->getHeaders()["response"]["content-type"]); // string(24) "text/html; charset=UTF-8" # Body response of the request var_dump($test3->getBody()); // string(51) "{...}"
POST SYNTAX
#Simple POST with NULL data $test0 = $CurlX->post("http://httpbin.org/post"); #POST with Data-form and Custom Headers $headers = array( "Host: httpbin.org", "my-custom-header: my-header-value" ); $test1 = $CurlX->post("http://httpbin.org/post", "test_ID=666&hello=mom", $headers); #POST with Json-Data and Custom Headers $data = array( "hello" => "mom", "key" => "value" ); $test2 = $CurlX->post("http://httpbin.org/post", $data, $headers); #POST with Custom-Data, Custom Headers, and Cookie $cookie = uniqid(); $test3 = $CurlX->post("http://httpbin.org/post", $data, $headers, $cookie); #POST with Json-Data, Custom Headers, Cookie and Proxy Tunnel $server = [ "method" => "tunnel", "server" => "47.254.145.99:3128" ]; $test4 = $CurlX->post("http://httpbin.org/post", $data, $headers, $cookie, $server); #After all requests were complete, you can delete the cookie file, Only when you use the $cookie parameter. $CurlX->deleteCookie(); # Response status of the request var_dump($test3->isSuccess()); // bool(true) # Status code of the request var_dump($test4->getStatusCode()); // int(200) # Content type of the request var_dump($test4->getHeaders()["response"]["content-type"]); // string(24) "..." # Body response of the request var_dump($test4->getBody()); // string(51) "{...}"
Other functions
// Set a custom option to current CURL structure $CurlX->setOpt([CURLOPT_HTTPAUTH => CURLAUTH_BEARER]); /** * Show all data process|errors of the request * * debug(): now supports cli and json print * * Recommended for develop work space */ $CurlX->debug();
More?
- More examples in examples dir.
Features
- International Domains and URLs
- Custom Tunnel Http with Proxy, Socks, Luminati, Apify, IpVanish
- Cookie data re-utilization
- Custom HTTP METHODS
Installation
Install source from GitHub
To install the source code:
$ git clone https://github.com/devblack/curlx.git
$ cd curlx
$ composer install
And include it in your scripts:
require_once __DIR__ . '/vendor/autoload.php';
use Thevenrex\Curlx\CurlX;
$CurlX = new CurlX();
Install with composer
Install library with composer package manager [php]
$ composer require thevenrexoff/curlx
Contribute
- Check for open issues or open a new issue for a feature request or a bug
- Fork the repository on GitHub to start making your changes to the
masterbranch (or branch off of it) - Write a test which shows that the bug was fixed or that the feature works as expected
- Send a pull request and bug me until I merge it
thevenrex/curlx 适用场景与选型建议
thevenrex/curlx 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 08 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 thevenrex/curlx 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 thevenrex/curlx 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-08-21