An 'import'-ant question

I have setup an application environment like this (other folders not specified):

— backend

-------- …

-------- config

-------- models

-------- components

-------- www

— common folder

-------- …

-------- models

-------- components

-------- config

— front end

-------- …

-------- models

-------- components

-------- config

-------- www

Lets say I am in the backend folder, I am importing the common models and the ones on the application, and I had a bit of a problem preloading the objects and I do not know if it is something to post a ticket or not but, depending on the order, it will import or not at all the models. I could check the code, but I believe it is interesting for all to know…




// THIS WAY WORKS

	'import'=>array(

		'site.common.components.*',

		'application.models.*',

		'application.components.*',

		'site.common.models.*',

	),


// THIS WAY WONT WORK

	'import'=>array(

                'site.common.models.*',

		'site.common.components.*',

		'application.models.*',

		'application.components.*',

	),



Path aliases are correct and shared models only in common/models folder. so, has anybody went through the same issue before?

Can you give an example of some model file that can’t be loaded? And in which folder it is? You may know that import alters the PHP include path, and the autoloader only tries to include the class file. So actually the logic is pretty basic and should work.

You could also try some debugging (requires change of YiiBase.php though) and output the include_path of PHP at the time of the error condition.

Thought exactly the same thing, the name of the class name not being able to be included is ‘Provider’, but check this, if I then move it from common folder to application folder… works

Will do the debugging as you suggested… I find it interesting…

… since i got the file just open: Try it at line 389 of YiiBase.php, right before it tries to include the class file. something like this maybe:




if ($className==='Provider')

    print_r(get_include_path());

Bit busy this morning sorry Mike… Will post it here asap

Don’t worry, i’m not sitting here, nervously waiting for your answer …

hahahaha aren’t you? lol thought this forum was addictive…

Here is the code as Mike suggested… the only different is that common components are… GOSH!

You know Mike? Thanks for the hint… I wont tell you what happened as I am ashamed… lol <I am doing some scrapping and left a file with same name ‘provider’ in a common components folder>

Anyway, I posted a reply so you can have a ‘rest’, no need to wait anymore

edit: +1 for the Hint… nice place to debug such things

Hehe, if you at least learned something, i’m happy, too… and thanks for the +1.

thanks…you saved me openning a new thread…got my answer.

phil