Download the PHP package maurice2k/multicurl without Composer
On this page you can find all versions of the php package maurice2k/multicurl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download maurice2k/multicurl
More information about maurice2k/multicurl
Files in maurice2k/multicurl
Package multicurl
Short Description Object-oriented asynchronous multi-curl wrapper
License MIT
Informations about the package multicurl
maurice2k/multicurl
Maurice\Multicurl
provides a powerful, easy-to-use object-oriented interface for PHP's curl_multi_*
functions, enabling high-performance concurrent HTTP requests with automatic connection management.
Beyond being just a wrapper, it includes a complete event loop system that intelligently manages concurrent connections, enforces connection limits, and handles both connection and total timeouts automatically.
Key Components
Manager
- Orchestrates multiple channels, handling the event loop and connection concurrency automatically.
HttpChannel
- The primary class you'll use for making HTTP requests. It provides a clean, fluent API for GET/POST requests, authentication, headers, redirects, and more.
Specialized Channels:
McpChannel
- Implements a "Streamable HTTP" client for the Model Context Protocol (MCP) for AI model communicationSseChannel
- Handles Server-Sent Events for real-time streaming
Installation
Install with composer:
Compatibility
Maurice\Multicurl
requires PHP 8.1 (or better) with the curl extension enabled.
Usage
Basic example
Outputs something like this:
Adding new channels on the fly
In this example we're implementing a super simple web crawler that starts at Wikipedia's "Web Crawler" page and extracts at most five new pages per crawled page until 20 pages have been put into the manager (successfully crawled or not).
A cleaner way would have been to create a HttpCrawlChannel
(extending HttpChannel
) that directly implements and overwrites HttpChannel's onReady
method (as well as onTimeout
and onError
).
Outputs something like this:
Create a MCP client using McpChannel
This example demonstrates how to use McpChannel
to connect to a remote MCP server and list available tools.
Works for newer MCP protocol version 2025-03-26 and above ("streamable HTTP").
Outputs something like this (will vary based on the server's available tools):
Testing
To run tests with a specific PHP version:
You can also run specific test types:
To run tests with all supported PHP versions (8.1, 8.2, 8.3, 8.4):
All versions of multicurl with dependencies
ext-curl Version >=8.1
ext-json Version >=8.1