symplify/symfony-route-usage

This package is abandoned and no longer maintained. The author suggests using the 50bhan/symfony-route-usage package instead.

Detect used and unused Symfony routes

Installs: 3 349

Dependents: 0

Suggesters: 0

Security: 0

Stars: 39

Watchers: 3

Forks: 0

Type:symfony-bundle

9.1.9 2021-02-14 21:16 UTC

README

Downloads total

Read about this package: How to Find Dead Symfony Routes


Inspired by Route Usage for Laravel:

"This package keeps track of all requests to know what controller method, and when it was called. The goal is not to build some sort of analytics but to find out if there are unused endpoints or controller method.

After a few years, any projects have dead code and unused endpoint. Typically, you removed a link on your frontend, nothing ever links to that old /special-page. You want to remove it, but you're not sure. Have look at the route_usage table and figure out when this page was accessed for the last time. Last week? Better keep it for now. 3 years ago? REMOVE THE CODE!"

Install

composer require symplify/symfony-route-usage

Register bundle to your config/bundles.php (in case Flex misses it):

return [
    Symplify\SymfonyRouteUsage\SymfonyRouteUsageBundle::class => [
        'all' => true,
    ],
];

Usage

Show used routes:

bin/console show-route-usage
used_routes.png

Show dead routes:

bin/console show-dead-routes
dead_routes.png

Configuration

By default, _* and error_controller is excluded. If you want to exclude more routes, use regex parameter:

# config/services.yaml
parameters:
    route_usage_exclude_route_regex: '#legacy#'

Report Issues

In case you are experiencing a bug or want to request a new feature head over to the Symplify monorepo issue tracker

Contribute

The sources of this package are contained in the Symplify monorepo. We welcome contributions for this package on symplify/symplify.