Download the PHP package qandidate/stack-request-id without Composer
On this page you can find all versions of the php package qandidate/stack-request-id. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download qandidate/stack-request-id
More information about qandidate/stack-request-id
Files in qandidate/stack-request-id
Package stack-request-id
Short Description Middleware for adding request id to Symfony Request.
License MIT
Informations about the package stack-request-id
stack-request-id
Middleware for adding a request id to your Symfony Requests
Installation
First, add this project to your project's composer.json
Setting up
Update your app.php
to include the middleware:
Before:
After:
Adding the request id to your monolog logs
If you use Symfony's MonologBundle you can add the request id to your monolog logs by adding the following service definition to your services.xml file:
Adding the request id to responses
If you need to send the request id back with the response you can enable the response header:
It is also possible to change response header's name:
If you don't have access to the RequestId
object instance (StackPHP, for example) the response header can be set via
the fourth argument of the RequestId
constructor method.
The third argument, for reference, is the name of the header:
- That will be checked for a value before falling back to generating a new request ID,
- Used to store the resulting request ID inside Symfony's request object.
StackPHP's Middleware Builder
If you are already using StackPHP, just push the RequestId
class into the builder.
All versions of stack-request-id with dependencies
symfony/http-foundation Version ^5.0.7
ramsey/uuid Version ^4.0