Models Manager not loading classes after adding namespace to project

I want to know how this work

$manager = new Phalcon\Mvc\Model\Manager(); $manager->registerNamespaceAlias('alias','namespace'); $manager->registerNamespaceAlias('alias','namespace');

i tried using this after i added to namespace to my project. I discovered queries with joins were no longer working. I keeps giving me cannot load class. I will appreciate any help on this please.

I think you've only created a local variable for the manager. Try registering the namespace on the global service:

// services.php
$di->setShared('modelsManager',function() {
    $manager = new ModelManager();
    $manager->registerNamespaceAlias('alias','Your\Namespace');
    return $manager;
});

or, late setting in an injectable interface:

public function someAction() {
    $this->modelsManager->registerNamespaceAlias('alias','Your\Namespace');
}