PHPackages                             orbeji/unused-routes - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. orbeji/unused-routes

ActiveSymfony-bundle[Debugging &amp; Profiling](/categories/debugging)

orbeji/unused-routes
====================

1.0(2y ago)03.9k↑27.8%MITPHPPHP &gt;=8.1

Since Jan 19Pushed 2y ago1 watchersCompare

[ Source](https://github.com/orbeji/unused-routes)[ Packagist](https://packagist.org/packages/orbeji/unused-routes)[ RSS](/packages/orbeji-unused-routes/feed)WikiDiscussions develop Synced 2d ago

READMEChangelogDependencies (13)Versions (3)Used By (0)

Unused Routes
=============

[](#unused-routes)

 [Report Bug](https://github.com/orbeji/unused-routes/issues) · [Request Feature](https://github.com/orbeji/unused-routes/issues)

[![Tests](https://github.com/orbeji/unused-routes/actions/workflows/tests.yml/badge.svg)](https://github.com/orbeji/unused-routes/actions/workflows/tests.yml/badge.svg)[![Static analysis](https://github.com/orbeji/unused-routes/actions/workflows/static.yml/badge.svg)](https://github.com/orbeji/unused-routes/actions/workflows/static.yml/badge.svg)[![Symfony & php compatibility](https://github.com/orbeji/unused-routes/actions/workflows/compatibility.yml/badge.svg)](https://github.com/orbeji/unused-routes/actions/workflows/compatibility.yml/badge.svg)

About The Project
-----------------

[](#about-the-project)

This project is a Symfony bundle that gives you information about the (un)used routes in your application. With this information you can safely delete the unused routes from your code.

[![](docs/screenshots/list.png)](docs/screenshots/list.png)

([back to top](#readme-top))

Getting Started
---------------

[](#getting-started)

### Installation

[](#installation)

Make sure Composer is installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

### Applications that use Symfony Flex

[](#applications-that-use-symfony-flex)

Open a command console, enter your project directory and execute:

```
$ composer require orbeji/unused-routes
```

### Applications that don't use Symfony Flex

[](#applications-that-dont-use-symfony-flex)

#### Step 1: Download the Bundle

[](#step-1-download-the-bundle)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

```
$ composer require orbeji/unused-routes
```

#### Step 2: Enable the Bundle

[](#step-2-enable-the-bundle)

Then, enable the bundle by adding it to the list of registered bundles in the `config/bundles.php` file of your project:

```
// config/bundles.php

return [
    // ...
    Orbeji\UnusedRoutes\UnusedRoutesBundle::class => ['all' => true],
];
```

Usage
-----

[](#usage)

After the installation the bundle will start registering the users activity. This activity will be stored by default in a file in `%kernel.logs_dir%/accessed_routes{Ymd}.log`

To know which routes are unused execute the following command:

```
php bin/console unused-routes:list
```

This will show a table like this:

```
---------------------- ------- -------------
  Route                  #Uses   Last access
 ---------------------- ------- -------------
  ux_live_component      0       -
  admin_index            0       -
  admin_post_index       0       -
  admin_post_new         0       -
  admin_post_show        0       -
  admin_post_edit        0       -
  admin_post_delete      0       -
  blog_rss               0       -
  blog_index_paginated   0       -
  blog_post              0       -
  comment_new            0       -
  blog_search            0       -
  security_login         0       -
  user_edit              0       -
  user_change_password   0       -
 ---------------------- ------- -------------
```

Also you can pass the option `--show-all-routes` to add the info of the used routes

```
php bin/console unused-routes:list --show-all-routes
```

This will show a table like this:

```
---------------------- ------- -------------
  Route                  #Uses   Last access
 ---------------------- ------- -------------
  ux_live_component      0       -
  homepage               4       16/01/2024
  admin_index            0       -
  admin_post_index       0       -
  admin_post_new         0       -
  admin_post_show        0       -
  admin_post_edit        0       -
  admin_post_delete      0       -
  blog_index             1       06/01/2024
  blog_rss               0       -
  blog_index_paginated   0       -
  blog_post              0       -
  comment_new            0       -
  blog_search            0       -
  security_login         0       -
  user_edit              0       -
  user_change_password   0       -
 ---------------------- ------- -------------

```

Now the routes that have been accessed also appear here with some info of the number of acceses and the date of the last one.

([back to top](#readme-top))

### Configuration

[](#configuration)

There are only two parameters in this bundle. The path where the file is stores and the filename.

```
unused_routes:
  file_path: '%kernel.logs_dir%'
  file_name: 'accessed_routes.log'
```

### Replacing how logs are stored/read

[](#replacing-how-logs-are-storedread)

If you want to replace the way of storing logs like using a database or another storaging strategy you can create your own service implementing the following interface:

```
