Hi.
I’m exporting an excel file with the above extension. And everything works fine, the file is generated correctly! But in app log I get the following:
Check your PHP files for blank lines before <?php. Is it only happening in that particular controller action or indepdently of the path (I assume the latter?).
Actually it happens just in that single action. The controller has no heading spaces, neither the model. They contain no echo or similar outputting calls.
What I don’t really get is why it’s throwing that error but also sending the file! If headers are already sent the file download shouldn’t start correctly, unless the browser is ignoring the first ones.
It’s a kind of mismatch between Yii 2 and the library.
\codemix\excelexport\ExcelFile::send() (or, precisely speaking, \mikehaertl\tmp\File::send() which is a dependency of the library) sends the response (the headers and the file content) by itself.
This is not a kind of behavior that Yii 2 expects from a library, because it is the framework that should send the response, as @machour says in a reply:
As you see in the source code of yii\base\application\end(), it is possible that Yii::$app->end() may send some headers trying to terminate the application in a decent manner.