Sometimes ‘yiic message’ complains about improper Yii::t() syntax.
It is hard to detect these error messages among all file names printed and it does not show the exact place in the source file.
An example for such error:
...
Extracting messages from C:\server\htdocs\apps\public_html\protected\views\site\topic\_topic_single_posts_page.php...
Extracting messages from C:\server\htdocs\apps\public_html\protected\views\site\topic\_topic_top.php...
Extracting messages from C:\server\htdocs\apps\public_html\protected\views\site\topic\edit.php...
PHP Parse error: syntax error, unexpected ')' in C:\server\htdocs\apps\yii\framework\cli\commands\MessageCommand.php(145) : eval()'d code on line 1
So the way I’ve found to pinpoint such errors is:
-
Run the command with redirection like … > C:\tmp\zz this will show only the errors on the console.
-
Add an echo line in yii\framework\cli\commands\MessageCommand.php line 144 so it will show all messages
$message=$matches[$i][2];
echo "message=$message\r\n"; // add this line
-
Run again. Look in the redirected file for error message like “Parse error:”. Find them in the source file just above the error and fix the bad Yii::t() line
-
Repeat step 3 until all errors are gone
Hope it helps someone
Yair