Skip to content

Add HttpCollector for comprehensive HTTP request/response tracking#1816

Closed
nasrulhazim wants to merge 1 commit intofruitcake:masterfrom
nasrulhazim:master
Closed

Add HttpCollector for comprehensive HTTP request/response tracking#1816
nasrulhazim wants to merge 1 commit intofruitcake:masterfrom
nasrulhazim:master

Conversation

@nasrulhazim
Copy link
Copy Markdown

Description

This PR adds a new HttpCollector data collector that provides comprehensive tracking of HTTP requests and responses in Laravel Debugbar.

Changes

New Files

  • src/DataCollector/HttpCollector.php - Main collector class
  • tests/DataCollector/HttpCollectorTest.php - Complete test coverage

Features

The HttpCollector provides detailed insights into HTTP requests and responses:

Request Information

  • Full URI, HTTP method, and controller action
  • Route middleware information
  • Request headers (with configurable hidden parameters for security)
  • Request payload including file uploads
  • Session variables

Response Information

  • HTTP status codes
  • JSON response parsing and formatting
  • Plain text response handling
  • Redirect URL detection
  • View responses with extracted data
  • HTML response indication

Performance Metrics

  • Request duration calculation from LARAVEL_START
  • Peak memory usage tracking

Security & Privacy

  • Configurable hidden request headers (e.g., Authorization, API keys)
  • Configurable hidden request parameters (e.g., password, token)
  • Configurable hidden response parameters
  • Configurable ignored status codes
  • Content size limits to prevent memory issues

Model Formatting

  • Eloquent model detection and formatting
  • Extracts model class, primary key, attributes, and relations
  • Handles nested relationships

Configuration

The collector supports the following constructor parameters:

new HttpCollector(
    request: $request,
    response: $response,
    startTime: LARAVEL_START,
    hiddenRequestHeaders: ['authorization', 'php-auth-pw'],
    hiddenParameters: ['password', 'password_confirmation'],
    hiddenResponseParameters: ['token', 'api_key'],
    ignoredStatusCodes: [404],
    sizeLimit: 64 // KB
)

@barryvdh
Copy link
Copy Markdown
Member

What is the difference with the regular collector? This collector is not registred automatically, right?

@beytullah-toprak
Copy link
Copy Markdown

It got better with the last update

@barryvdh
Copy link
Copy Markdown
Member

barryvdh commented Jan 2, 2026

What is the difference?

@barryvdh
Copy link
Copy Markdown
Member

Sorry I don’t understand the benefit. I don’t want the content because it might be large. I did add an HttpRequest collector in the new php-debugbar release, and implemented it for the http client requests.

@barryvdh barryvdh closed this Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants