samluvanda/http-client
最新稳定版本:v1.0.0
Composer 安装命令:
composer require samluvanda/http-client
包简介
A lightweight PHP HTTP client powered by cURL, offering retries, flexible headers, and fluent response parsing.
README 文档
README
📘 Introduction
A lightweight, fluent PHP HTTP client built entirely with cURL — no dependencies, no bloat. This library gives you complete control over requests and responses while maintaining readability and simplicity in your codebase.
Designed for developers who value minimalism, precision, and testability in API communication.
🚀 Why Use This Client?
- ✨ Fluent, expressive syntax
- 💡 Full control over headers, body, query params, and more
- ⚙️ Built-in retry, timeout, and error handling mechanisms
- 📦 Smart JSON parsing and collection-style access
- 🔎 Rich status code and response helpers
- 🔐 Supports all major auth schemes (Basic, Digest, Bearer, NTLM)
- 🧵 Pure cURL — zero third-party HTTP layers
💾 Installation
composer require samluvanda/http-client
Requirements:
- PHP 8.0+
curlPHP extensionsamluvanda/collection
🧪 Quick Example
use HttpClient\Client; $client = new Client(); $response = $client ->withHeaders(['Authorization' => 'Bearer token']) ->withQueryParameters(['search' => 'books']) ->get('https://example.com/api/items'); if ($response->ok()) { print_r($response->json()); } else { echo "Request failed with status: " . $response->status(); }
You may also handle errors explicitly using fluent methods:
$response->throwIf(fn($res) => $res->status() >= 400);
📚 Full Documentation
See docs/DOCUMENTATION.md for comprehensive usage instructions, supported methods, chaining examples, and advanced features like file uploads and raw body sending.
✅ Minimum Requirements
- PHP >= 8.0
- cURL extension
samluvanda/collectionfor JSON and array-like access
🤝 Contributing
Contributions, bug reports, and feature suggestions are welcome!
- Read the CONTRIBUTING.md guide
- Submit issues or PRs via GitHub
💖 Sponsor This Project
If you find this HTTP client useful, consider showing your support!
☕ Buy me a coffee, fuel my late-night coding sessions, or just say thanks
📬 s_luvanda@hotmail.com
🌍 github.com/samluvanda
Every star, share, and sponsor keeps this project alive and evolving! 🚀✨
📄 License
This project is open-sourced under the MIT license.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-11