Download the PHP package 2a/symfony-performance-analyzer without Composer
On this page you can find all versions of the php package 2a/symfony-performance-analyzer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download 2a/symfony-performance-analyzer
More information about 2a/symfony-performance-analyzer
Files in 2a/symfony-performance-analyzer
Package symfony-performance-analyzer
Short Description Bundle to monitor and analyze performance of Symfony applications
License MIT
Homepage https://github.com/ajenguianis/symfony-performance-analyzer
Informations about the package symfony-performance-analyzer
Symfony Performance Analyzer Bundle
A powerful toolkit for monitoring and optimizing Symfony applications, offering real-time performance metrics, N+1 query detection, cognitive complexity analysis, automated reporting, a secure web dashboard, and seamless CI/CD integration.
Features
- π Real-time Performance Metrics: Monitor request response time, database queries, memory usage, and CLI command performance.
- π N+1 Query Detection: Identify and resolve N+1 query issues with detailed analysis.
- π§ Cognitive Complexity Analysis: Detect complex code structures (threshold > 10) to improve maintainability.
- π Automated Reporting: Generate HTML, JSON, or SVG badge reports for CI/CD pipelines.
- π Secure Web Dashboard: Visualize performance trends and metrics at
/_performance
. - π Performance Alerts: Configurable thresholds for response time, memory usage, query count, and complexity.
- πΎ Flexible Storage: Store data using Doctrine ORM (
DatabaseStorage
) or JSON files (FileStorage
) with retention policies. - π Internationalization: Supports English and French translations.
- π Extensibility: Add custom analyzers, collectors, and event listeners.
- β Standards Compliance: Enforced with PHPStan (max level), PHPUnit (100% coverage), ECS, and Rector.
- β‘ Performance Optimizations: Request sampling, degraded mode, and circuit breaker for external services.
Installation
Install the bundle via Composer:
Enable the bundle in config/bundles.php
:
Generate and apply database migrations (for database storage):
Install assets for the web dashboard:
Configuration
Create a configuration file at config/packages/symfony_performance_analyzer.yaml
:
For file-based storage, ensure the storage directory is writable:
Usage
CLI Commands
Analyze performance and generate reports:
Example JSON report output:
Web Dashboard
Access the performance dashboard at /_performance
. Secure it by enabling the firewall and restricting IP access:
Customize the dashboard route in config/routes.yaml
:
Debug Toolbar
The bundle integrates with Symfonyβs debug toolbar, displaying request time, query count, memory usage, and performance issues. Enable it in the configuration:
Performance Metrics
The bundle collects and analyzes the following metrics:
Metric | Description | Expected Range | Source |
---|---|---|---|
Request Time | HTTP request execution time | 0β500 ms | PerformanceTracker , Timer |
Database Queries | Query count, duration, and N+1 issues | 0β50 queries | DatabaseQueryCollector , QueryAnalyzer |
Memory Usage | Peak memory consumption | 0β256 MB | MemoryAnalyzer |
Cognitive Complexity | Code complexity score | 0β10 | CognitiveComplexityAnalyzer |
CLI Performance | Command execution time | 0β5000 ms | PerformanceTracker |
Issues | Performance violations detected | 0β10 issues | AnalysisResult |
Custom Analyzers
Create a custom analyzer by implementing AnalyzerInterface
:
Register the analyzer in config/services.yaml
:
Custom Collectors
Create a custom collector by implementing CollectorInterface
:
Register the collector:
Performance Considerations
- Request Sampling: Set
sampling.rate
to a value less than 1.0 (e.g., 0.1 for 10% of requests) in production to reduce overhead. - Degraded Mode: Enable
sampling.degraded_mode
to skip non-essential collectors when response time exceedsdegraded_threshold_ms
. - Circuit Breaker: Activate
circuit_breaker.enabled
to protect against external service failures, with configurable failure thresholds and retry timeouts. - Data Retention: Configure
storage.retention
to limit database or file storage growth, specifying retention days and maximum records. - Overhead: Performance tests ensure tracking overhead is below 5ms per request.
Testing
Run the test suite:
Perform static analysis and linting:
The bundle includes:
- Unit Tests: Cover all services and components (100% coverage).
- Integration Tests: Validate end-to-end workflows with database storage.
- Performance Tests: Measure tracking overhead.
- Edge Case Tests: Handle database failures and high-load scenarios.
Uninstallation
Remove the bundle:
Drop database tables (if using database storage):
Remove configuration files and assets:
Contributing
- Fork the repository.
- Create a feature branch:
git checkout -b feature/my-feature
- Commit changes:
git commit -am 'Add my feature'
- Push to the branch:
git push origin feature/my-feature
- Open a Pull Request.
Ensure all tests pass and adhere to coding standards (ECS, Rector, PHPStan).
License
This bundle is licensed under the MIT License. See the LICENSE file for details.
All versions of symfony-performance-analyzer with dependencies
symfony/framework-bundle Version ^7.0
nikic/php-parser Version ^5.0
doctrine/orm Version ^3.0
symfony/asset Version ^6.0|^7.0
symfony/console Version ^7.0
symfony/dependency-injection Version ^6.0|^7.0
symfony/http-kernel Version ^6.0|^7.0
symfony/twig-bundle Version ^7.0
guzzlehttp/guzzle Version ^7.0