Reputation: 11265
For example I have Yii project in location /var/www/yii
. How to get this path from controller?
What I try Yii::app()->basePath;
I get /var/www/yii/module-name
.
I need only /var/www/yii
. Of course I can modify this URL with str_replace()
, but maybe there is a way to get clearly this root?
Upvotes: 1
Views: 372
Reputation: 14459
You can get it like below:
echo Yii::getPathOfAlias('webroot');
This will return the result you want:
var/www/yii/
If you want to get your application path, you can:
echo Yii::getPathOfAlias('application');
Upvotes: 2
Reputation: 531
Is it an option to get the parent directory of the given path using dirname
?
http://php.net/manual/en/function.dirname.php
Upvotes: 0