2017 © Pedro Peláez
 

symfony-bundle route-statistics-bundle

This Symfony2 bundle lets you analyze your logs or profiler data to rank your routes.

image

secotrust/route-statistics-bundle

This Symfony2 bundle lets you analyze your logs or profiler data to rank your routes.

  • Tuesday, November 1, 2011
  • by snc
  • Repository
  • 1 Watchers
  • 8 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

RouteStatisticsBundle

About

This bundle scans your log files or the profiler data and displays an ordered overview of the matched routes. You can use this output to optimize the order of the routes to speed up the matching., (*1)

Installation

Append the following lines to your deps file:, (*2)

[SecotrustRouteStatisticsBundle]
    git=http://github.com/secotrust/SecotrustRouteStatisticsBundle.git
    target=/bundles/Secotrust/Bundle/RouteStatisticsBundle

then run the php bin/vendors install command., (*3)

Register the Secotrust namespace in the autoloader:, (*4)

``` php <?php // app/autoload.php $loader->registerNamespaces(array( // ... 'Secotrust' => DIR.'/../vendor/bundles', // ... ));, (*5)


Register the bundle in your application's kernel: ``` php <?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Secotrust\Bundle\RouteStatisticsBundle\SecotrustRouteStatisticsBundle(), // ... ); ... }

Usage

The bundle adds the router:statistics command. You can specify the --format argument (default: profiler) which can be one of apache, nginx, profiler, symfony or a regular expression which extracts the method and the path info from a log line. When you are not using the profiler or symfony format then you can optionally specify a path info prefix, for example /app_dev.php which will be removed from the extracted path info., (*6)

The output contains the following informations:, (*7)

  • Match count
  • Route name
  • Position of the route in the matcher class

To optimize the routing you should try to move the most used routes to the top. Remember that the first matching route always wins., (*8)

Examples

php app/console router:statistics
21: _wdt (#11)
 5: _demo (#8)
 4: _configurator_step (#20)
 3: _demo_secured_hello (#6)
 3: _welcome (#1)
 3: _demo_login (#2)
 2: _demo_secured_hello_admin (#7)
 2: _demo_hello (#9)
 1: _configurator_final (#21)
 1: _configurator_home (#19)

When using the symfony format the command looks for lines containing request.INFO: Matched route., (*9)

php app/console router:statistics --format symfony app/logs/dev.log

If you want to analyze your apache or nginx log files (combined log type) your command should look like this:, (*10)

php app/console router:statistics --format apache /var/log/apache2/access-prod.log

Or if your log contains the front controller script name:, (*11)

php app/console router:statistics --format apache --prefix "/app_dev.php" /var/log/apache2/access-dev.log

Known issues

  • Currently the output differs a bit, symfony does not always log the matched route in the app log.
  • When using web server logs, the scheme is unknown.

The Versions

01/11 2011

dev-master

9999999-dev https://github.com/secotrust/SecotrustRouteStatisticsBundle

This Symfony2 bundle lets you analyze your logs or profiler data to rank your routes.

  Sources   Download

MIT

The Requires

 

by Henrik Westphal

route symfony routing performance