Path to some file in console commands

Hello, I write my own console command, but I get some strange error, when in config I try to set the path to file using:


Yii::getPathOfAlias('webroot') . '/path/to/file.php'

or


Yii::app()->getBasePath() . '/path/to/file.php'

It always return string '/path/to/file.p in my command class. What I am doing wrong ? :huh:

The config file is read before the application object is constructed (the config is passed to the object for construction). You won’t be able to access the application object at that point, and, presumably, the path aliases will be incorrect.

You should be able to build those paths from within the commands themselves.

Thanks for advice :)