Is there a way to add more directories to one namespace?

I know its dirty, but I need it. Given my class:

<?php
namespace Ext;

which is in work\Ext directory, so:

<?php
$loader = new \Phalcon\Loader();
$loader->registerNamespaces(array(
  'Ext' => 'work\Ext'
));
$loader->register();

but sadly, this namepsace can be in other directories. So I would like to type:

<?php
$loader = new \Phalcon\Loader();
$loader->registerNamespaces(array(
  'Ext' => array(
    'work\Ext',
    'work\Ext\ext2')
));
$loader->register();

which is not possible

edited Dec '15

Phalcon is handling namespace register in psr-0/psr-4 way i guess. So if there is namespace Ext/ext2 then only register work/Ext should be enough. Also folders should be lowercase and namespaces starting upper case.



12.9k

yea, but just moving this class to this subdirectory doesnt seem to work

Are you sure its the right namespace and filename ? try lowecase folder names. Class name have to the same name as filename, for example if you registernamespace Ext in folder work\ext

And then you want to use for example class Ext\Ext2\SomeClass

Then you need SomeClass.php file with class name SomeClass and path work\ext\ext2\SomeClass.php