Download the PHP package ctw/ctw-middleware-responsetime without Composer

On this page you can find all versions of the php package ctw/ctw-middleware-responsetime. 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 ctw-middleware-responsetime

Package "ctw/ctw-middleware-responsetime"

Latest Stable Version GitHub Actions

PSR-15 middleware that adds an X-Response-Time header showing request processing duration in milliseconds.

Introduction

Why This Library Exists

Understanding how long your application takes to process requests is essential for performance monitoring and optimization. While external tools can measure total response time, they include network latency. Measuring at the application level provides the true processing time.

This middleware adds an X-Response-Time header to every response showing:

Problems This Library Solves

  1. Invisible performance: Without timing data, slow requests go unnoticed
  2. External tool inaccuracy: Network-based measurements include latency, not just processing time
  3. Manual instrumentation: Adding timing code to every handler is tedious and error-prone
  4. Inconsistent measurement: Different timing implementations across the application
  5. Missing production visibility: Development profilers aren't available in production

Where to Use This Library

Design Goals

  1. High precision: Milliseconds with three decimal places (microsecond resolution)
  2. Accurate timing: Uses REQUEST_TIME_FLOAT as start time for precision
  3. Standard format: X.XXX ms format is human-readable and parseable
  4. Minimal overhead: Simple subtraction and header addition
  5. Universal application: Works for HTML, JSON, and all response types

Requirements

Installation

Install by adding the package as a Composer requirement:

Usage Examples

Basic Pipeline Registration (Mezzio)

ConfigProvider Registration

Response Header Output

Inspecting with cURL

Inspecting in Browser DevTools

  1. Open Developer Tools (F12)
  2. Navigate to the Network tab
  3. Select a request
  4. View Response Headers
  5. Look for X-Response-Time

Header Format

Component Description
Value Processing time in milliseconds
Precision Three decimal places (microsecond resolution)
Format X.XXX ms
Example 45.123 ms

Timing Calculation

The middleware calculates response time as:

Where:

Use Cases

Log Analysis

Performance Alerting

Load Testing


All versions of ctw-middleware-responsetime with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
ctw/ctw-middleware Version ^5.0
psr/container Version ^1.0 || ^2.0
psr/http-message Version ^1.1 || ^2.0
psr/http-server-handler Version ^1.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 ctw/ctw-middleware-responsetime contains the following files

Loading the files please wait ...