I have been having a heck of a time getting the loader to work properly in a few different situations. I need to use both registerNamespaces and registerDirs to get it to work, which does not make sense to me, since all my classes are in namespaces.
One specific problem I have is that my app_role table cannot be found by the loader when referencing it, although my organization table can be found without a problem:
$this->belongsTo('organization_id', "Organization", 'id', ['alias' => 'Organization', 'foreignKey' => TRUE]); $this->belongsTo('role_id', 'AppRole', 'id', ['alias' => 'AppRole', 'foreignKey' => TRUE]); ... $name = $this->organization->name; echo "NAME: $name<br/>"; $name = $this->appRole->name; echo "NAME: $name<br/>";
The appRole->name causes a "cannot redeclare class AppRole" exception, no matter what case I use to reference it. The organization->name works just fine. The two classes are nearly identical. I've tried using \App\Models\AppRole in the class, with and without a leading slash. I've tried a require_once of the class, and many other things. Nothing seems to work.
I am new to Phalcon, and have been a Yii user for 5+ years. I've also worked reently with Nette, Slim and RedBean. I like the idea of a compiled MVC framework, and when it works Phalcons seems very intuitive. But with cases like this one can spin one's wheels a long time. Any help would be appreciated.