Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Curl Bundle Laravel Package

zeroem/curl-bundle

zeroem/curl-bundle is a Symfony bundle that wraps cURL in a simple, configurable HTTP client service. Make GET, POST, and custom requests with headers, options, and error handling, then inject the client anywhere via Symfony's service container.

View on GitHub
Deep Wiki
Context7

Getting Started

Install & register. The package is a Symfony 2 bundle, not a Laravel package — there is no service provider and no package auto-discovery. Install it with Composer and, on the Symfony side, register new Zeroem\CurlBundle\ZeroemCurlBundle() in AppKernel. If you are in a Laravel app, the practical entry point is the underlying zeroem/curl library classes (Zeroem\Curl\Curl, the multi-handle manager, and the HttpKernel\CurlClient). You will wire them into the Laravel container yourself rather than relying on bundle services.

Look here first.

  • Resources/config/services.yml — the canonical list of service ids and their arguments. Everything else in the bundle is composed from these.
  • HttpKernel/CurlClient.php — the HttpKernelInterface implementation. This is the interesting piece: it lets you drive a Request through cURL and get a Response back.
  • The Curl facade class wrapping curl_multi_* — this is what you will reach for in application code.

First use case. Pick one of two:

  1. Parallel outbound HTTP — the facade lets you enqueue several handles, execute them together, and collect results. This is the reason you would tolerate a Symfony 2 bundle in a modern codebase.
  2. HTTP-level functional tests — the HttpKernelInterface client is a drop-in for Symfony's Client that goes over the wire with cURL instead of the PHP stream wrapper, so it exercises real sockets, timeouts, and TLS.

Implementation Patterns

Batch calls through the curl_multi facade. The natural workflow is: create N Curl handles, add each to the facade, run the multi-exec loop, and reduce the responses. Model this behind a small service (e.g. ApiBatchFetcher) so your app code never touches curl_* functions directly. The facade gives you per-handle completion callbacks, which is the cleanest way to fan results back into typed DTOs.

HttpKernel client as a test harness. Because it implements HttpKernelInterface, you can inject the cURL client wherever Symfony expects an HttpKernel and call handle(Request) — useful for acceptance tests against a staging URL, and for exercising your own controllers over HTTP without booting a full web server. In Laravel, wrap it in a helper trait and use it inside feature tests when $this->get() against the in-process kernel is not faithful enough (e.g. you need real redirects or real TLS).

Handles are the unit of work, not requests. Treat a Curl handle as a reusable, configured request template: set URL/options once, clone per call. This keeps the multi loop simple and avoids re-parsing options each iteration. Store the return value of curl_multi_add_handle so you can pair it with curl_multi_info_read during the exec loop.

Integration tips.

  • Bind the facade and the client as singletons in the Laravel container; the multi handle is stateful and should not be re-created per request inside a single job.
  • Keep the HttpKernel client behind a config flag (services.http.curl_client) so tests can swap in a mock.
  • If you only need one-off requests, use Guzzle or Laravel's Http facade — this package earns its place only when you need curl_multi_* semantics or the HttpKernelInterface client.

Gotchas and Tips

  • It is not a Laravel package. No service provider, no facade alias, no config file. You will be instantiating classes manually or writing a thin provider. Do not expect php artisan integration.
  • PHP and Symfony version drift. The bundle targets the Symfony 2 / PHP 5.x era. Check composer.json constraints before pulling it into a PHP 8 project; you may need to fork or extract the zeroem/curl library alone.
  • Handle leaks in the multi loop. Always curl_multi_remove_handle and curl_close in a finally block. If you return early from the exec loop on a failed handle, unclosed handles accumulate and eventually exhaust file descriptors — the symptom is mysterious CURLE_COULDNT_CONNECT errors under load.
  • No PSR-7 / PSR-18. Responses are cURL-shaped (strings, error codes), not typed HTTP messages. Normalise to your own DTO or PSR-7 early if you plan to swap in Guzzle later.
  • TLS defaults. Do not disable CURLOPT_SSL_VERIFYPEER to "fix" connection issues. The bundle exposes standard cURL options; set a CA bundle path instead.
  • Debugging. Enable CURLOPT_VERBOSE on a single handle and route output to a log, and always inspect curl_errno / curl_error per handle after the multi loop — errors are per-handle, not global, so a silent failure on one request is easy to miss.
  • Extension points. The HttpKernelInterface client is the clean seam: decorate it to add logging or retries without touching the facade. The multi facade is harder to decorate because it drives the loop internally — prefer wrapping it in your own service rather than subclassing.
  • Where it shines. If you have a legacy Symfony 2 service or a batch job that already speaks curl_multi, adopting this bundle is cheaper than a rewrite. For new Laravel code, borrow the idea — parallel handles behind a service — and implement it with Guzzle's pool, which is maintained and PSR-compliant.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
cgv/localized-resource