This doesn't work in all cases. On one project of mine, $_SERVER['DOCUMENT_ROOT'] is /var/www/public_html while Yii::getPathOfAlias('webroot') is /var/www/public_html/fi. Admittedly my setup is a bit weird in that the /fi part is a symlink to "..".