tourze/symfony-profiler-markdown-bundle

A Symfony bundle that exports Symfony Profiler data as Markdown format for easy sharing and archiving

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:symfony-bundle

pkg:composer/tourze/symfony-profiler-markdown-bundle


README

English | δΈ­ζ–‡

A Symfony bundle that exports Symfony Profiler data as Markdown format, making it easy to share and archive profiling reports.

πŸš€ Features

  • Markdown Export: Export Symfony Profiler data to well-formatted Markdown
  • Multiple Collectors: Supports all standard Symfony profiler collectors (Request, Time, Memory, Security, Doctrine, etc.)
  • Extensible Formatters: Customizable formatter system for different data types
  • Direct Access: Access profiler reports via /_profiler/{token}.md endpoint
  • Rich Formatting: Includes tables, code blocks, and emoji indicators for better readability

πŸ“¦ Installation

Install the bundle using Composer:

composer require tourze/symfony-profiler-markdown-bundle

βš™οΈ Configuration

1. Enable the Bundle

Add the bundle to your config/bundles.php:

// config/bundles.php
return [
    // ...
    Tourze\ProfilerMarkdownBundle\ProfilerMarkdownBundle::class => ['all' => true],
];

2. Configure Dependencies

This bundle requires the following bundles:

  • DoctrineBundle (for database profiling)
  • SecurityBundle (for security profiling)
  • RoutingAutoLoaderBundle (for automatic route loading)

Make sure these are enabled in your application.

πŸ”§ Usage

Basic Usage

Once installed, you can access any profiler report in Markdown format by visiting:

http://your-app.com/_profiler/{token}.md

Replace {token} with the actual profiler token from your Symfony toolbar.

Example URL

http://localhost:8000/_profiler/a1b2c3d.md

This will generate a comprehensive Markdown report including:

  • Summary: Request overview with token, URL, method, status, time, IP
  • Table of Contents: Navigation links to all collector sections
  • Detailed Sections: Formatted data from each profiler collector:
    • πŸ“¨ Request: HTTP request details, headers, parameters
    • ⏱️ Performance: Execution time, timeline data
    • πŸ’Ύ Memory: Memory usage statistics
    • πŸ”’ Security: Authentication and authorization details
    • πŸ—„οΈ Database: Doctrine queries and performance metrics
    • 🎨 Templates: Twig rendering information
    • πŸ“‹ Logs: Application log entries
    • And more...

🎨 Formatters

The bundle includes specialized formatters for different data types:

Built-in Formatters

  • RequestFormatter: HTTP request/response data
  • TimeFormatter: Performance timing data
  • MemoryFormatter: Memory usage statistics
  • SecurityFormatter: Security events and decisions
  • DoctrineFormatter: Database queries and metrics
  • TwigFormatter: Template rendering data
  • LoggerFormatter: Log entries with levels and formatting

Custom Formatters

You can create custom formatters by implementing MarkdownFormatterInterface:

<?php

use Tourze\ProfilerMarkdownBundle\Formatter\MarkdownFormatterInterface;
use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;

class CustomFormatter implements MarkdownFormatterInterface
{
    public function supports(DataCollectorInterface $collector): bool
    {
        return $collector instanceof YourCustomCollector;
    }

    public function format(DataCollectorInterface $collector): array
    {
        // Return array of Markdown lines
        return [
            "## Custom Data",
            "",
            "| Property | Value |",
            "|----------|-------|",
            "| Custom Field | Custom Value |",
            "",
        ];
    }

    public function getPriority(): int
    {
        return 0; // Higher priority = earlier execution
    }
}

πŸ” Example Output

# Symfony Profiler Report

---

## πŸ“Š Summary

| Property | Value |
|----------|-------|
| **Token** | `a1b2c3d` |
| **URL** | https://example.com/api/users |
| **Method** | GET |
| **Status** | 200 |
| **Time** | 2024-01-15 14:30:25 |
| **IP** | 127.0.0.1 |

---

## πŸ“‘ Table of Contents

- [πŸ“¨ Request](#request)
- [⏱️ Performance](#time)
- [πŸ’Ύ Memory](#memory)
- [πŸ”’ Security](#security)
- [πŸ—„οΈ Database](#doctrine)

---

## πŸ“¨ Request

| Property | Value |
|----------|-------|
| Method | GET |
| URI | /api/users |
| Parameters | `{}` |
| Headers | `{"host":"example.com",...}` |

πŸ› οΈ Development

Running Tests

composer test

Code Quality

composer phpstan

πŸ“„ Requirements

  • PHP 8.1+
  • Symfony 7.3+
  • Doctrine Bundle
  • Security Bundle
  • Twig

πŸ“ License

This bundle is licensed under the MIT License. See the LICENSE file for details.

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“ž Support

For issues and questions: