Help determining the best way to generate text files

Published 1 month ago by madsynn

Can you guys help me. I am trying to generate text files that contain the looped data from each crud when a button is pushed. Can anyone help me i have never had to do something like this with laravel before and i am at a loss on how to do it.

lets say crud is called config i need to print all values from config into a text.txt file in the public folder. Do i do this with a controller and use that to loop through it and create the text file when the button is pushed or is there a better and easier way to make this happen.

Any of your thoughts an suggestions would be very helpful and welcome please.

Thank you for the help in advance.

Best Answer (As Selected By madsynn)
Snapey

pushing the button in the client should trigger the request in the controller, then use the Storage helper to save the raw data

https://laravel.com/docs/5.7/filesystem#storing-files

If assembling the data gets too heavy for a controller, outsource it to a dedicated class

jlrdw
jlrdw
1 month ago (252,600 XP)

I'm on mobile now if you search the PHP manual there are all kinds of functions to work with files, like fopen etc.

madsynn

@jlrdw Sorry i should have been more clear. I am not looking for the best functions or php ways to write the files im looking for the best way to create the process in laravel.

Using controllers or listeners or custom provider or any other means of making this work best in laravel.

Snapey
Snapey
1 month ago (1,040,195 XP)

pushing the button in the client should trigger the request in the controller, then use the Storage helper to save the raw data

https://laravel.com/docs/5.7/filesystem#storing-files

If assembling the data gets too heavy for a controller, outsource it to a dedicated class

jlrdw
jlrdw
1 month ago (252,600 XP)

im looking for the best way to create the process in laravel.

Fyi that is php. That sentence does not even make sense.

Maybe you will be lucky enough to never need json_decode.

Please sign in or create an account to participate in this conversation.