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. cego/curl-handle-reuse-laravel-octane

ActiveLibrary

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

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

0.2.2(1mo ago)221.8k↓17.5%1[1 PRs](https://github.com/cego/curl-handle-reuse-laravel-octane/pulls)MITPHPPHP ^8.2CI passing

Since Dec 10Pushed 1mo 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 1mo ago

READMEChangelog (4)Dependencies (14)Versions (6)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

47

—

FairBetter than 94% of packages

Maintenance90

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% 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 ~157 days

Total

4

Last Release

53d 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 (10 commits)")[![faytekin](https://avatars.githubusercontent.com/u/4013224?v=4)](https://github.com/faytekin "faytekin (2 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

[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

320244.3k6](/packages/tzsk-sms)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[bayareawebpro/laravel-multistep-forms

Responsable MultiStep Form Builder for Laravel.

967.9k](/packages/bayareawebpro-laravel-multistep-forms)

PHPackages © 2026

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