basePath

The docs define basePath as: "the root directory of the application."

So, why does echo Yii::app()->basePath; always return /mypath/protected/ ?

It would be far more useful if it returned the expected /mypath/

It seems we have nice easy properties for all the expected directories: modulePath, extensionPath,runtimePath,basePath(/protected/) except the actual root.

How about adding one?

maybe this is an option?

http://www.yiiframework.com/doc/api/CHttpRequest#scriptFile-detail

dirname(Yii::app()->request->scriptFile)

take a look here

Thanks, I knew there was a way, but still think it should be a property like the others :)

basePath point to ‘/protected’ may be convention.

you can get the "/yourWeb" relative URL by baseUrl property;

I am after the full file system path. This is for simple procedures such as a user uploading images. As such, it should be available as a standard property.

dirname(Yii::app()->request->scriptFile) works, so that is what I will use.

you can config you main.php,




params = array(

...

'webRoot' => dir(dirname(__FILE__).DIRECTORY_SEPARATOR.'..')

)



call Yii::app()->params[‘webRoot’], :rolleyes:

That just throws an error:


Object of class Directory could not be converted to string

leave out the dir()

I think we have lost the point of my first post and now are looking at everything that does NOT work.

My original point was that a property that points to the root directory of the application should be available, just as it is for other directories such as modulePath, extensionPath, runtimePath etc.

you can request this feature here

http://www.yiiframework.com/forum/index.php?/forum/10-feature-requests/

the dev team will decide B)

Doh! Thanks! :P

modify


'webRoot' => dir(dirname(__FILE__).DIRECTORY_SEPARATOR.'..')

to


'webRoot' => dirname(dirname(__FILE__).DIRECTORY_SEPARATOR.'..')


Yii::getPathOfAlias('webroot')

CORRECTION:


YiiBase::getPathOfAlias('webroot')

CORRECTION OF CORRECTION: ;)

Yii extends YiiBase so Yii::getPathOfAlias() is valid.

Sure? That’s strange, didn’t worked for me when tried it.

Yes, just verified that it really works. What error do you get?

What about…


Yii::app()->basePath . '../';

:)