KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Couldn't save pdf file into local storage using Laravel command line #2400

Open Gopal opened this topic on on Oct 21, 2021 - 3 comments

Gopal commented on Oct 21, 2021

Hi,

I am facing an issue when I use Laravel command to generate a report and send it via email.

Below code working in when I execute it through web route. It saves files into the local folder.

$report->export()->pdf()->saveAs("sakila.pdf");

But when I use the Laravel command, it's not working (not saving files) and throwing an error as below:

PHP Notice:  Undefined index: REQUEST_URI in /myproject/vendor/koolreport/export/Handler.php on line 193

Please can you help me here?

Let me know if I can explain further.

Thanks

KoolReport commented on Oct 21, 2021

If you want to generate report and send it via email then you should not use toBrowser() function. you should save the pdf file with saveAs() to save file to a folder and then attach the file to email to send out.

Gopal commented on Oct 21, 2021

Thank you for your quick response.

It was a mistake in my comment. (Edited previous comment)

I have tried saveAs('filename.pdf'), since it's also not working.

Please can you help with that?

Thanks

Sebastian Morales commented on Oct 22, 2021

Gopal, for KoolReport's pdf export to work it needs to be executed via web server to get $_SERVER's REQUEST_URI and several other information to load the report's resources (js, css, image files, etc) to render them all.

The fastest solution for your case would be setting up a specific route for export and your Laravel command is to send a get/post request to that route. That way the web server would execute the export and save pdf files for you instead of executing via command line. Let us know if you need further detail. Tks,

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None