The Slim Framework support forum has moved to This Tender forum is no longer maintained or monitored.

Including a whole folder

Koby Bentata's Avatar

Koby Bentata

02 Jun, 2015 08:35 AM

There is any way i can include all the files of a folder in slim? like autoloading a folder?

  1. 1 Posted by Qiniso on 02 Jun, 2015 11:22 AM

    Qiniso's Avatar

    Yes, you can use the DirectoryIterator class

    $sFolder = 'path/to/files';
    $oIterator = new DirectoryIterator($sFolder);
    foreach ($oIterator as $oFileInfo) {
        if ($oFileInfo->isFile()) {
            include $sFolder . '/' . $oFileInfo->getFilename();

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac