Loader & namepsace: can't create a \Phalcon\Tools namespace

Hi all,

I'm building a MVC app with 6 different modules, and I guess as many before me, I'd like to instanciate a "custom set" of shared tools & libraries I can use in my modules. I obviously don't want to load everything all the time in my bootstrap or module.php files.

!! Tools means a set of classes to help manage dates, urls, xml, ... a bunch of stuffs like this !!

So I thought I could create a \Phalcon\Tools namespace, containing a "tool-loader" class. I could register this custom loader as a service in the bootstrap and use it to load my libs when I need it. Problem is, I can't get it to work. Here is my setup.

App structure:


In my boostrap:

$di->get('loader')->registernamespaces(array('\\Phalcon\\Tools' => PATH_CLASS.'/tool_loader.php'), true)->register();
$di->setShared('tools', function () use($di) 
    return new \Phalcon\Tools\Loader($di);

In tool.loader.php

namespace \Phalcon\Tools;

class Loader

Result: Fatal error: Class 'Phalcon\Tools\Loader' not found

Could anyone tell me what I'm doing wrong. Thanks in advance

What do you get when you dump


Just to confirm your path is correct

edited May '15

That's the first thing I've checked. Require(PATH_CLASS.'/tool_loader.php'); works just fine.


Actually if I add my a require_once(PATH_CLASS.'/tool_loader.php'); in my boot strap, it works. It seems like the loader is not working properly in my setup...