Question: **How to easily list all routes that we have defined in our application with Zend Framework** 2?

By "routes" I mean those which are defined in:

`module/[moduleName]/config/module.config.php`

under

```
'router' => array(
    'routes' => array(
        ...
    )
)

```

I need to list them all but I can't figure out how to do this easily and nor the documentation nor the forums helped me by now.

Answer: 
To get all routes I use [ZFTool](http://framework.zend.com/manual/current/en/modules/zendtool.introduction.html)

And console command to get dump of routes:

```
php vendor/bin/zf.php config list | grep routes

```

For Windows users (not tested):

```
php vendor/bin/zf.php config list |  findstr /R /C:"[routes]"

```
You can get a list of routes from the router using the following code snippet. `$mvcEvent` is an instance of `Zend\Mvc\MvcEvent` and `TreeRouteStack` is `Zend\Router\Http\TreeRouteStack`.

```php
$router = $mvcEvent->getRouter();
$routes = (array) $router->getRoutes();
$routes = array_values($routes);
$routes = count($routes) > 0 ? array_keys($routes[0]) : [];

```