Question: I have worked with many MVC frameworks and now i am developing a website using Slim Framework. I like it as it is very lightweight.

Only problem is how do i manage my file structure as writing all the routes and its closure functions in a single file will not be manageable as the size of application grows.

Answer: 
Assuming you have folder that should contain all your routes:

```
$dir = 'path/to/routes';

foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS)) as $file){
  require $file;
}

```

Slim is not really fs aware, which is a good thing.  

Routes should be declared with a name anyways, so the filename or directory they are in is of little consequence for the framework itself.

You might want to optimize it for yourself however, thus sub directory's are recommended.

If you don't want to use sub-directory's you can remove the `RecursiveIteratorIterator` from the loop, or just include 1 file that includes them all.
I've had good success with breaking routes into different files grouped by usage or intent and simply using `require_once` for each file. It's simple, explicit, and keeps things pretty well organized, IMO.

Keeping all the route files in one place is important as well, so I usually put my routes into their own subdirectory. I've used `/routes`, `/src/routes`, and `/app/routes`, all with equal success.

The last bit of my `/public/index.php` file generally looks something like this:

```
<?php

// ... snip ...

require_once dirname(__DIR__) . '/app/routes/auth.php';
require_once dirname(__DIR__) . '/app/routes/default.php';
require_once dirname(__DIR__) . '/app/routes/admin.php';

// $app is an instance of \Slim\App
$app->run();

```