Tips for Yii. Chapter 9.
Sending and saving a file for downloading with the help of the sendFile function.
Properly speaking, an example:
The first parameter what is sent into the function by sending a file to a user is a file’s name.
The second parameter is a file’s content.
As the third parameter you can manually specify a file’s mimeType, that is ‘null’ as default (it is set automatically).
The fourth parameter can be set as a flag - true/false. It will be used to terminate the running of the application or not after calling the function sendFile, ‘true’ as default.
If a profiler is enabled (logging), for instance a yii-debug-toolbar extension, add a calling of a disableProfiler method before calling a sendFile function (this method is available only the Open Real Estate CMS):
(you can see the code of the method in the protected\components\Controller.php file)
It is necessary to prevent profile’s notes from being added to a file’s content by downloading.
Sending and saving large files for downloading with the help of the xsendFile function.
A site of the web developer is https://tn123.org/mod_xsendfile/
Its using in the Yii:
The function is very similar to Yii::app()->request->sendFile (besides all the advantages it is clearly shown what parameters and keys for what functions are responsible, so I will not write about it).
Installation and setting of xSendFile for XAMPP:
Multilanguages in Yii. Search for untranslated words/phrases/sentences.
An onMissingTranslation event will help us.
In config/main.php:
The first value of the array is a class name, and the second value is a method name in this class.
The code of the CustomEventHandler class in the protected\components\CustomEventHandler.php file is the following: