Custom module including library folder


I’m having a bit of trouble moving my code into the ‘library’ folder in my custom module. I have the following layout:

Inside /usr/share/icingaweb2/modules/statusblocks:

- application
  - clicommands
  - controllers
    - HelloController.php
  - forms
  - locale
  - views
- doc
- library
  - StatusBlocks
    - File.php

My library class looks like this:


namespace Icinga\Module\StatusBlocks;

use DirectoryIterator;

class File
    public static function listFiles($path)
        $result = array();

        foreach (new DirectoryIterator($path) as $file) {
            if ($file->isDot()) continue;

            $result[] = (object) array(
                'name' => $file->getFilename(),
                'path' => $file->getPath(),
                'size' => $file->getSize(),
                'type' => $file->getType()
        return $result;

And my controller looks like this:

namespace Icinga\Module\StatusBlocks\Controllers;
use Icinga\Web\Controller;
use Icinga\Module\StatusBlocks\File;

class HelloController extends Controller
    public function worldAction()
        $this->view->files = Hello::listFiles($this->Module()->getBaseDir());

I get the following error:
Uncaught Error: Class 'Icinga\Module\StatusBlocks\Blocks\File' not found in /usr/share/icingaweb2/modules/statusblocks/application/controllers/HelloController.php:10

If I manually include the file in the controller like this:
include_once "/usr/share/icingaweb2/modules/statusblocks/library/StatusBlocks/File.php";

… it works fine. But I’m pretty sure I shouldn’t have to do that - I was under the impression the /library/ folder was all included/autoloaded?

Can anyone suggest what I might have done wrong?
Thank you so much!!!

I found the problem (2 hours later…)

Obvious really - the namespace/class name cannot include CamelCase -
should be

Hope this helps someone else… :smiley: