byjg / webrequest
A lightweight PSR-7 implementation and highly customized CURL wrapper for making REST calls.
Fund package maintenance!
byjg
Installs: 467 987
Dependents: 10
Suggesters: 0
Security: 0
Stars: 5
Watchers: 1
Forks: 5
Open Issues: 1
pkg:composer/byjg/webrequest
Requires
- php: >=8.1 <8.4
- ext-curl: *
- ext-json: *
- byjg/uri: ^5.0
- psr/http-client: ^1.0
- psr/http-factory: ^1.0|^1.1
- psr/http-message: ^1.0|^2.0
Requires (Dev)
- ext-soap: *
- phpunit/phpunit: ^9.6
- vimeo/psalm: ^5.9
Provides
README
A lightweight PSR-7 implementation and highly customized CURL wrapper for making REST calls.
Overview
PHP WebRequest is a fully PSR-compliant HTTP client package that provides:
PSR Implementations
- ✅ PSR-7 - HTTP Message Interface (Request, Response, Stream)
- ✅ PSR-17 - HTTP Factories (Request, Response, Stream, etc.)
- ✅ PSR-18 - HTTP Client Interface
Additional Features
- Helper classes for common request types (JSON, Form URL Encoded, MultiPart)
- Support for parallel HTTP requests
- Mock client for testing
Documentation
- HTTP Messages and Factories (PSR-7/PSR-17) - Create and manipulate HTTP requests, responses, and streams
- Sending HTTP Requests (PSR-18) - Send HTTP requests with customizable options (proxy, SSL, timeouts)
- Parallel Requests - Execute multiple HTTP requests concurrently for better performance
- Testing with Mock Client - Test HTTP code without real network calls
- Request Helpers - Quickly build JSON, Form, and MultiPart requests
- Comparison with Guzzle - How WebRequest compares to Guzzle HTTP client
Basic Example
<?php // Create a request $uri = \ByJG\Util\Uri::getInstanceFromString('http://www.example.com/page'); $request = \ByJG\WebRequest\Psr7\Request::getInstance($uri); // Send the request $response = \ByJG\WebRequest\HttpClient::getInstance()->sendRequest($request); // Process the response $statusCode = $response->getStatusCode(); $body = $response->getBody()->getContents();
Install
composer require "byjg/webrequest"
Running Tests
# Start the test server docker-compose up -d # Run the tests vendor/bin/phpunit # Stop the server docker-compose down
Dependencies
flowchart TD
byjg/webrequest --> psr/http-message
byjg/webrequest --> psr/http-client
byjg/webrequest --> ext-json
byjg/webrequest --> byjg/uri
Loading