What I want to do :
User hit a url (ex: BASE-URL/download/json).
Code fetch huge data from database and stream it into a JSON file and user is prompted to download that file.
What I tried :
Created a large (700 MB) JSON file.
Tried opening it with code, but error was thrown.
file_get_contents($file)
Error :
Allowed memory size of XXX bytes exhausted (tried to allocate YYY bytes)
I am working in Symfony2. Data can be upto 700MB in size. Can't increase the allocated memory. How can I achieve this? Please comment if any further information is required.