vkoori/guzzle-wrapper
最新稳定版本:0.1.2
Composer 安装命令:
composer require vkoori/guzzle-wrapper
包简介
A flexible PHP-based API client built on Guzzle, supporting dynamic body formats, complex query parameters, retry logic with exponential backoff, and robust exception handling.
关键字:
README 文档
README
A flexible PHP-based API client built on Guzzle, supporting dynamic body formats, complex query parameters, retry logic with exponential backoff, and robust exception handling.
Install
composer require vkoori/guzzle-wrapper
// Create a GuzzleClient instance $client = new \Vkoori\GuzzleWrapper\GuzzleClient(); // Perform a POST request with extensive chaining $response = $client ->setBaseUrl('https://api.example.com') // Set the base URL ->endpoint('users') // Set the endpoint (e.g., /users) ->headers([ // Set custom headers 'X-Custom-Header' => 'CustomHeaderValue', ]) ->accept('application/json') // Set the Accept header ->withToken('your-api-token-here') // Set Authorization header with Bearer token ->userAgent('MyCustomUserAgent/1.0') // Set a custom User-Agent header ->connectTimeout(2.0) // Set connection timeout to 2 seconds ->timeout(5.0) // Set overall request timeout to 5 seconds ->retry(3, 300000) // Retry up to 3 times with increasing delay ->asJson() // Use JSON format for the request body ->data([ // Add JSON data for the request body 'name' => 'John Doe', 'email' => 'john@example.com', 'password' => 'secretpassword', ]) ->post(); // Send a POST request // Response echo (string) $response->getBody();
统计信息
- 总下载量: 425
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2024-10-24