How to access all routes from Slim 3 php framework?
<p>I am trying to build a dynamic drop-down menu from routes defined in Slim framework and here is my question - is there a way to access all defined static routes from some kind of array?</p>

<p>For instance, if I define my routes like this:</p>

<pre><code>// Index page: '/'
require_once('pages/main.php');

// Example page: '/hello'
require_once('pages/hello.php');

// Example page: '/hello/world'
require_once('pages/hello/world.php');

// Contact page: '/contact'
require_once('pages/contact.php');
</code></pre>

<p>Each file is a separate page that looks like this</p>

<pre><code>// Index page
$app-&gt;get('/', function ($request, $response, $args) {

    // Some code

})-&gt;setName('index');
</code></pre>

<p>I would like to access all of these defined routes from some sort of array and then use that array to make a unordered HTML list in my template files.</p>

<pre><code>&lt;ul&gt;
  &lt;li&gt;&lt;a href="/"&gt;Index&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="/hello"&gt;Hello&lt;/a&gt;
    &lt;ul&gt;
       &lt;li&gt;&lt;a href="/hello/world"&gt;World&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href="/contact"&gt;Contact&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>Whenever I change defined routes, I would like this menu to change with it. Is there a way to achieve this?</p>