PHPackages                             cego/curl-handle-reuse-laravel-octane - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. cego/curl-handle-reuse-laravel-octane

ActiveLibrary[HTTP &amp; Networking](/categories/http)

cego/curl-handle-reuse-laravel-octane
=====================================

Utility for convenient usage of singleton curl handles using Laravel HTTP facade

0.2.3(3w ago)225.6k↓44.6%1MITPHPPHP ^8.2CI passing

Since Dec 10Pushed 3w ago5 watchersCompare

[ Source](https://github.com/cego/curl-handle-reuse-laravel-octane)[ Packagist](https://packagist.org/packages/cego/curl-handle-reuse-laravel-octane)[ RSS](/packages/cego-curl-handle-reuse-laravel-octane/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (5)Dependencies (21)Versions (7)Used By (0)

Curl Handle Reuse for Laravel Octane
====================================

[](#curl-handle-reuse-for-laravel-octane)

Motivation
==========

[](#motivation)

Per default in most PHP applications, a new curl handle is created for each outgoing request, which will require a new TCP connection to be established, and a TLS handshake to be performed if the request is made over HTTPS.

The TLS handshake can be a big performance penalty for applications that strive for low latency, as it requires 2 round trips between the client and the server for the TLS handshake, and one round trip for the TCP connection. This can easily reach 100ms and more depending on your round trip latency to the server.

Solution
========

[](#solution)

This package, by default, replaces the bind for the Http facade, to use the same curl handle for all outgoing requests.

It works by binding a Guzzle handle in the service container as a "true"-singleton. To reuse across requests, worker mode must be used, such as in Laravel Octane.

It then automatically rebinds the Http facade to automatically use this singleton, so you don't have to change your code. It is a minimally invasive change to the Http client, and no code changes should be required to use it.

You can also use the bound Guzzle handle in other HTTP clients, by resolving `\Cego\CurlHandleReuseLaravelOctane\ReusedCurlHandle::class` from the service container.

Installation
============

[](#installation)

```
composer require cego/curl-handle-reuse-laravel-octane
```

Contributing
============

[](#contributing)

Feel free to open issues or pull requests if you have any suggestions or improvements. Remember to run php-cs-fixer, unittests and phpstan before opening a pull request.

Performance
===========

[](#performance)

You can expect to reduce the latency of outgoing requests by 3 times the latency roundtrip. The speedup factor will depend on the latency of the server you are connecting to, compared to the execution time of the endpoint you are calling.

For example if you have a server with a 100ms roundtrip latency, and the endpoint takes 100ms to execute, then you are likely to see a speedup from 400ms to 200ms.

Benchmarks
----------

[](#benchmarks)

See tests/Benchmark for a simple PHPBench setup that pings github.com/robots.txt 50 times with and without the package. With the package, a prewarmed curl handle is used. The round-trip latency was measured to approximately 19.5ms.

```
+---------------------------+----------------------------------------------------+----------+-----------+-----------+-----------+--------+---------+
| benchmark                 | subject                                            | memory   | min       | max       | mode      | rstdev | stdev   |
+---------------------------+----------------------------------------------------+----------+-----------+-----------+-----------+--------+---------+
| HttpReusedCurlHandleBench | benchHttpWithoutReusedCurlHandle ()                | 16.581mb | 77.222ms  | 77.222ms  | 77.222ms  | ±0.00% | 0.000μs |
| HttpReusedCurlHandleBench | benchHttpWithReusedCurlHandle ()                   | 16.607mb | 20.812ms  | 20.812ms  | 20.812ms  | ±0.00% | 0.000μs |
| HttpReusedCurlHandleBench | benchHttpWithReusedCurlHandleMultipleOrigins ()    | 18.103mb | 47.237ms  | 47.237ms  | 47.237ms  | ±0.00% | 0.000μs |
| HttpReusedCurlHandleBench | benchHttpWithoutReusedCurlHandleMultipleOrigins () | 18.078mb | 181.377ms | 181.377ms | 181.377ms | ±0.00% | 0.000μs |
+---------------------------+----------------------------------------------------+----------+-----------+-----------+-----------+--------+---------+

```

As can be seen, the benchmark of querying github.com/robots.txt 50 times is reduced from 77.222ms to 20.812ms, which is approximately 3x roundtrip latency of 19.5ms. (it would be equivalent to roundtrip latency of 18.8ms)

See also
--------

[](#see-also)

Aaron Francis has covered this topic in a video on his YouTube channel, where he explains the performance benefits of reusing curl handles in Laravel Octane. You can watch the video here:

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance95

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~137 days

Total

5

Last Release

25d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d79d2046d4c647d13783eaedebc0044f9e824fd211e2b23281aaf727222e3f2?d=identicon)[cego](/maintainers/cego)

---

Top Contributors

[![LauJosefsen](https://avatars.githubusercontent.com/u/44977457?v=4)](https://github.com/LauJosefsen "LauJosefsen (11 commits)")[![faytekin](https://avatars.githubusercontent.com/u/4013224?v=4)](https://github.com/faytekin "faytekin (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cego-curl-handle-reuse-laravel-octane/health.svg)

```
[![Health](https://phpackages.com/badges/cego-curl-handle-reuse-laravel-octane/health.svg)](https://phpackages.com/packages/cego-curl-handle-reuse-laravel-octane)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58171.8k14](/packages/api-platform-laravel)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k91.9k1](/packages/mike-bronner-laravel-model-caching)[illuminate/auth

The Illuminate Auth package.

10528.2M1.2k](/packages/illuminate-auth)[illuminate/routing

The Illuminate Routing package.

1419.2M3.0k](/packages/illuminate-routing)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
