Download the PHP package gemvc/http-client without Composer
On this page you can find all versions of the php package gemvc/http-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package http-client
gemvc/http-client
Multi-Environment PHP HTTP Client Package
Synchronous and Asynchronous API Calls for Apache, Nginx, and Swoole
Part of Gemvc , a lightweight PHP Framework for microservices
Overview
A framework-independent HTTP client package providing both synchronous and asynchronous API call capabilities. Automatically adapts to your runtime environment (Apache, Nginx, or Swoole) for optimal performance.
Features
- ✅ Synchronous API calls with retry logic and SSL support
- ✅ Asynchronous concurrent requests with configurable concurrency
- ✅ Enhanced error handling with exception storage and classification
- ✅ Environment-aware execution - optimized for each runtime (Native Coroutines for Swoole)
- ✅ Framework-independent - use in any PHP project
- ✅ Backward compatible with GEMVC framework
Installation
Requirements
- PHP 8.2 or higher
- cURL extension
- OpenSwoole extension (optional, for optimized async in Swoole)
Quick Start
Synchronous Client
Asynchronous Client
Fire-and-Forget (Non-Blocking)
Environment-Specific Implementations
The package provides environment-specific implementations:
- HttpClient - Apache/Nginx synchronous implementation
- AsyncHttpClient - Apache/Nginx asynchronous implementation
- SwooleHttpClient - Native Swoole implementation using Coroutines (no cURL dependency)
API Reference
HttpClient Methods
AsyncHttpClient Methods
Framework Integration (GEMVC)
In GEMVC framework, the package is automatically used via wrapper classes:
The framework provides:
- Environment detection via
WebserverDetector - Seamless integration with existing
ApiCallandAsyncApiCallclasses - 100% backward compatibility
Error Handling
The package provides comprehensive error handling with automatic exception classification:
Exception Types
HttpClientException- Base exception for all HTTP client errorsNetworkException- Network-related errors (DNS, connection, SSL, etc.)TimeoutException- Request timeout errors (connection or total timeout)
Error Storage
All exceptions are automatically stored in the $errors array property, allowing you to inspect errors without try-catch blocks:
Network Error Classification
Network errors are automatically classified by type:
Testing
Test coverage: 85.30% with comprehensive error handling tests.
License
MIT License - See LICENSE file for details
Contributing
Contributions welcome! Please follow:
- PSR-12 coding standards
- PHPStan Level 9 type safety
- Comprehensive test coverage
GemVC , Lightweight PHP Framework Built for Microservices Made with ❤️ by Ali Khorsandfard