We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Namespace autoloating

I've created a config item for autoloading namespaces:

   'additionalNamespaces' => array(
        'Voice' => __DIR__ . '/../../app/library/' . '/Voice',
        'Phalcon' => array(
            '/Users/stephenhoogendijk/phalcon-incubator/Library/Phalcon',
            __DIR__ . '/../../app/library/' . '/Phalcon'
        )
    )
/**
 * Load additional namespaces from the config if there any present
 */
if(is_array($config->additionalNamespaces)) {

    $loader->registerNamespaces(
        $config->additionalNamespaces
    );
}

But it doesn't seem to take, can't you define namespaces in multiple directories?

The reason we are doing this is because we want to define our own components in the library dir under /phalcon before making a pull request for the incubator.



98.9k

You must pass 'true' as second parameter of registerNamespaces to merge the existing directories to the new ones

$loader->registerNamespaces($config->additionalNamespaces, true);


8.1k

@Phalcon maybe i'm missing something, but it still says:

Fatal error: Class 'Phalcon\Cache\Backend\Redis' not found in /private/var/www/voice/app/library/Voice/Cache.php on line 16 

Note: I am using v1.2.0 now



98.9k

Multiples directories for a same prefix aren't supported, Is that you're looking for?