Download the PHP package bilfeldt/laravel-correlation-id without Composer

On this page you can find all versions of the php package bilfeldt/laravel-correlation-id. 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 laravel-correlation-id

Deal with Request-ID and Correlation-ID in Laravel applications

Latest Version on Packagist Tests StyleCI Code Style Status Total Downloads

Create request Correlation-IDs via middleware and pass both this globally unique Correlation-ID and any user provided Request-ID to the global log context.

Version Laravel PHP
1.* 10. | 11. 8.1. | 8.2. | 8.3.*

Motivation

Each and every request should have a unique Correlation ID which uniquely determines the user interaction. This Correlation ID should then be added to all log entries as context, to error reporting and to any subsystem like external API calls or queued jobs. Doing so, makes is possible to track relevant touch points for a given user request. Read more here.

A client can also provide a Request ID which it is good practice to return again in the response and correlate to the Correlation ID. Read more here.

Installation

You can install the package via composer:

Assigning Correlation ID to requests

[!NOTE] Ideally, the unique Correlation ID should be created at the very first touch point of your infrastructure like the initial server which could be a load balancer

As it can be tricky to create Correlation ID on the server level and this is so easy in Laravel using middleware. This package provides a middleware for creating a Correlation ID and attaching it to the request as a header Correlation-ID and to the response header as well. You should either assign the correlation id on the first touch point of your infrastructure or register the CorrelationIdMiddleware middleware globally as the first middleware in the $middleware property of your app/Http/Kernel.php class:

Assigning Request ID to responses

If the client provides a Request ID in the request header, then it is good practice to copy that to the response header. This is done by adding the ClientRequestIdMiddleware middleware globally in the $middleware property of your app/Http/Kernel.php class:

Usage

This package registers a few macros on the Illuminate\Http\Request class:

Add global log context

It is possible to add both the Correlation ID and the Request ID to the global log context so that any writing to logs once those are added will automatically have the id's attached as context.

It is recommended to add them to the logging context just after assigning them to the request. This can be done by globally registering the middleware LogContextMiddleware in the $middleware property of your app/Http/Kernel.php class:

Add global context to error reporting

It is possible to add both the Correlation ID and the Request ID to the global error reporting context so that any error reporting once those are added will automatically have the id's attached as context.

If the variables have already been added to the log context, then I recommend merging all the global log context to the error reporting context overriding the context method of your application's App\Exceptions\Handler:

Alternatively if you do not want to share all the global log context, simply fetch the IDs from the request() helper using the macros described above:

Passing Correlation ID and Request ID to queued jobs

This package make sure that the Correlation ID and the Request ID are passed to the payload of queued jobs which can be retreived again using $job->payload()['data'].

Just before a queued job is being processed, then we extract the Correlation ID and the Request ID from the payload and sets those on the Illuminate\Http\Request instance, so that any subsequent jobs that could get dispatched will also have them attached.

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-correlation-id with dependencies

PHP Build Version
Package Version
Requires php Version ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0
illuminate/contracts Version ^10.0 || ^11.0
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 bilfeldt/laravel-correlation-id contains the following files

Loading the files please wait ....