How to config messages folder path?

How to config messages folder path?

The message source path can be configured with Yii::app()->message->basePath (see CPhpMessageSource)

Or in config/main.php


You have to adjust your config/message.php accordingly

Thx, but not solved, message is readonly.

The key “message” is not readonly, it’s simply wrong.

Instead of "message" try "messages". And it has to be within "components". So it look likes this:

'components' => array(



Please set the path of messages using ALIAS like :

'components' => array(



Here getPathOfAlias(‘application.messages’) will return path/to/webroot/project-folder-if/protected/messages

Please refer to the Yii Guide for more information about path aliases

You could give path directly instead of using Yiibase::getPathOfAlias(…) using php

dirname function but it will not be flexible if you change the location of your application.

Hope this will help!


This one:


It’s return false in my config file. Anyone know how make this with the same effect ?

The config/main.php will be included before the alias path’s (application, ext, webroot …) are added.

So you can’t use Yii::getPathOfAlias(‘’) in config/main.php.




But ‘application.messages’ is the default for PHPMessageSource, so you don’t have to assign this path in the config file.