Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Does \Phalcon\Loader follow PSR-4? (can I map one namespace to multiple directories?)

Hey guys, take the following structure as an example:



both classes are using the namespace MyApp.

$user = new \MyApp\Users();
$auth = new \MyApp\Auth();

I tried setting up the loader as follows but it doesn't work. It seems the last one overrides the first one:

$loader = new \Phalcon\Loader();
        'MyApp' => MODELS_PATH, #this will be ignored
        'MyApp' => LIBRARY_PATH.'/MyApp/'               

Shouldn't this be possible based on PSR-4?


I read the reference but I clearly missed that paragraph. Thanks for the reply but keep in mind that it's more useful to copy & paste the answer instead of saying RTFM! ;)

edited Oct '15

I'm sorry you interpreted my link to mean that and I'm quite hurt by your comment and find your wink insulting.

As Tom Waits once paraphrased "In the land of the blind, the one-eyed man is King".

I did guide you to the relevant paragraph. I don't know the manual like the back of my hand either and I certainly have no expectation of other people to either. In my defence I personally find it usefull to understand what I'm reading in the best context which in this case I personally found was the manual.

I'm sorry my response was usefull but not exactly tailored to your need or anyone else who may agree with you.

If you were being friendlier you might have said "Oh yeah I hadn't seen that" and left it at that. I certainly wouldn't have minded and find clues in your response to possible hidden assumptions about my character I find insulting.

Perhaps if its more usfull to copy and paste the answer in you might paste it in for everybody else yourself. I notice you hadn't and preferred to idly complain.

Also I might point out that link used references the latest documentation.

Who knows if your question relates the documentation as it currently stands? I know I wouldn't. But the original question still stands.

Though I do recognise your point may stand. Its just something to be aware of when reading examples in forums.


Hey buddy, I'm sorry if you felt offended but it wasn't my intention! You did help me somewhat with the link (I still think there's a bug somewhere, I'm testing that right now) but I just wanted to point that for an answer to be more useful to everybody, it would be better to include the pertinent part of the document you provided the link for. The wink was to make sure you would interpret it as a friendly comment ;) Thanks.

edited Oct '15

After some tests I found out that Phalcon\Loader doesn't follow the PSR-4 specification. I'm not sure if this is a feature they intentionally left out, but I filed a repport.

Edit: Phalcon is aware of the issue and a fix is expected!


Its not hard to rub an insomniac up the wrong way.

I hope you find the answer you're looking for and your bug. ;)