Download the PHP package cego/curl-handle-reuse-laravel-octane without Composer

On this page you can find all versions of the php package cego/curl-handle-reuse-laravel-octane. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package curl-handle-reuse-laravel-octane

Curl Handle Reuse for Laravel Octane

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

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

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

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

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.

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

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: https://www.youtube.com/watch?v=BWAocgJVCbw


All versions of curl-handle-reuse-laravel-octane with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/http Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0
ext-curl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package cego/curl-handle-reuse-laravel-octane contains the following files

Loading the files please wait ....