KoolReport's Forum

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

Cloud Export PHP Warning: file_get_contnents("...."): failed to open stream #2265

Closed George opened this topic on on Aug 17, 2021 - 11 comments

George commented on Aug 17, 2021

The pdf successfully downloads to where I want it to. However, I am getting many php warnings when using pdf cloud export.

[16-Aug-2021 23:27:39 UTC] PHP Warning:  file_get_contents(http://localhost:8888/config/189581fcb7c8ac21237e492618c87f55.js): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
 in /Users/keithko/Documents/code/kinder_reports/vendor/koolreport/cloudexport/vendor/chromeheadlessio/php-client/src/Exporter.php on line 192
[16-Aug-2021 23:27:39 UTC] PHP Warning:  file_get_contents(http://localhost:8888/config/7c6bd7c097b8a097521387ff77ceee36.js): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
 in /Users/keithko/Documents/code/kinder_reports/vendor/koolreport/cloudexport/vendor/chromeheadlessio/php-client/src/Exporter.php on line 192
[16-Aug-2021 23:27:39 UTC] PHP Warning:  file_get_contents(http://localhost:8888/config/6477a69291e53bdfa0ea501af56c5e0a.js): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
 in /Users/keithko/Documents/code/kinder_reports/vendor/koolreport/cloudexport/vendor/chromeheadlessio/php-client/src/Exporter.php on line 192
[16-Aug-2021 23:27:39 UTC] PHP Warning:  file_get_contents(http://localhost:8888/config/79f8d1792bdcb90589020c91804479f2.js): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
 in /Users/keithko/Documents/code/kinder_reports/vendor/koolreport/cloudexport/vendor/chromeheadlessio/php-client/src/Exporter.php on line 192
[16-Aug-2021 23:27:39 UTC] PHP Warning:  file_get_contents(http://localhost:8888/config/573fba7315e0423cce17cb649db3e70b.js): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
 in /Users/keithko/Documents/code/kinder_reports/vendor/koolreport/cloudexport/vendor/chromeheadlessio/php-client/src/Exporter.php on line 192
[16-Aug-2021 23:27:39 UTC] PHP Warning:  file_get_contents(http://localhost:8888/config/9d239a4fb27648cfc08aadd3d9560a51.js): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
 in /Users/keithko/Documents/code/kinder_reports/vendor/koolreport/cloudexport/vendor/chromeheadlessio/php-client/src/Exporter.php on line 192
[16-Aug-2021 23:27:39 UTC] PHP Warning:  file_get_contents(http://localhost:8888/config/7fbbf5c44b32b33abe39f384f0594337.js): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
 in /Users/keithko/Documents/code/kinder_reports/vendor/koolreport/cloudexport/vendor/chromeheadlessio/php-client/src/Exporter.php on line 192

I have useLocalTempFolder set to true, and I see the temp files being downloaded to a tmp config/tmp/611af94a11b3c folder. However for some reason file_get_contents is trying to find it one folder outside.

It seems like the unique id isn't being added to the path? $tempDirName = uniqid(); in Exporter.php's saveTempContent function.

email.php: `

    $file_directory = $_SERVER['DOCUMENT_ROOT']."/tmp_files/";
    $report_template_str = "../../config/ReportPDF";
    $file_name = $report_title."-".date("ymdhis").$_SESSION["user_id"];
    $file_name .=".pdf";

    $report->cloudExport($report_template_str)
    ->chromeHeadlessio(".....")
    ->settings([
        "useLocalTempFolder" => true
    ])
    ->pdf([
        "scale" => 0.5,
        //"format" => "A4",
        "landscape" => true,
    ])
    ->saveAs($file_directory.$file_name);

Any help is appreciated.
Sebastian Morales commented on Aug 17, 2021

Pls open the file koolreport/cloudexport/composer.json and change the following line:

        "chromeheadlessio/php-client": "^1.1.0"

to this one:

        "chromeheadlessio/php-client": "^1.2.0"

Then run the following command in koolreport/cloudexport in a command line/terminal:

compose update

Install compose before hand if you haven't. Verify that chromeheadlessio/php-client is updated to version 1.2.0 by opening the file koolreport/cloudexport/vendor/chromeheadlessio/php-client/composer.json and see its version field.

Finally try cloud export again and let us know the result. Tks,

George commented on Aug 17, 2021

All the old warnings were removed, only two new but similar warnings remain.

[17-Aug-2021 13:33:29 UTC] PHP Warning:  file_get_contents(http://localhost:8888/vendor/koolreport/amazing/assets/core/../img/logo.png): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
 in /Users/keithko/Documents/code/kinder_reports/vendor/koolreport/cloudexport/vendor/chromeheadlessio/php-client/src/Exporter.php on line 12
[17-Aug-2021 13:33:29 UTC] PHP Warning:  file_get_contents(http://localhost:8888/vendor/koolreport/amazing/assets/core/../img/logo-symbol.png): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
 in /Users/keithko/Documents/code/kinder_reports/vendor/koolreport/cloudexport/vendor/chromeheadlessio/php-client/src/Exporter.php on line 12

Do I need to update another package?

Sebastian Morales commented on Aug 18, 2021

Can you open this link in your browser?

http://localhost:8888/vendor/koolreport/amazing/assets/core/../img/logo.png

George commented on Aug 18, 2021

I get a 'Not Found The requested URL was not found on this server.'

I also checked my vendow/koolreport/amazing/assets/core folder. The only assets are amazing.css, amazing.min.css, bootstrap.bundle.min.js and bootstrap.min.js.

Sebastian Morales commented on Aug 19, 2021

Ok, where is your ".../img/logo.png"? file and what is its path that you created in your pdf view?

George commented on Aug 19, 2021

There actually is no logo.png file in my project folder. Was this supposed to be downloaded by KoolReport?

The path is a tmp_files folder in the root of my project folder. The directory structure is like this

---config
      |---email.php
---kl-sample
---reports
---tmp_files
---vendor
      |---koolreport
.gitignore
.README.md
Sebastian Morales commented on Aug 20, 2021

Pls post your pdf view file's code for us to check it. Tks,

George commented on Aug 24, 2021

Here is the pdf view file:

<?php

use koolreport\datagrid\DataTables;

?>
<html lang="en-US">

    <head>
        <link rel="stylesheet" type="text/css" href="global-theme.css?ver=<?= ASSET_VERSION ?>"/>
        <script src="https://code.jquery.com/jquery-3.5.1.js"></script>

        <h6>header</h6>
        <?php
        echo $_SESSION['export_pdf_html_header'];
        ?>
    </head>
    <body>
        <style>
        .print_head {
            margin-bottom: 20px;
            margin-top: 7px;
            color: #666 !important;
        }
        h6{
            padding-left: 20px;
        }
        .print_title {
            font-weight: bold;
            font-size: 17px;
        }
        .titleInfo {
            padding-left: 20px;
        }
        .company_logo {
            height: 30px;
        }

        .column-left{ float: left; width: 33.333%; }
        .column-right{ 
            float: right; 
            width: 33.333%;
            padding-left: 450px;
        }
        .column-center{ 
            display: inline-block; 
            width: 33.333%;
            padding-left:175px;
        }
        .table th, .table td{
            padding: 10px 5px 10px 5px !important;

        }

        @media print{
        * {
            -webkit-print-color-adjust: exact !important;
        }   
            @page {
                size: landscape;
            }
        }

        #table_footer td:first-child{
            background: black;
            color: #374354 !important;
        }
        .table th,#table_footer td{
            background: #374354 !important;
            color: white !important;
        }
        .table-striped > tbody > tr:nth-of-type(odd) > td {
                background-color: #f9f9f9 !important;
        }

        </style>

    <input type='hidden' id='footer_value' name='footer_value' value='<?php echo $_SESSION['footer_value']?>'>
    <?php
        DataTables::create($_SESSION['data_table_array']);
    ?>
    <script>
        const footer_val = $('#footer_value').val()
        if(footer_val == 1){
            $('tbody tr:last').attr('id','table_footer');
        }
    </script>
    </body>
</html>

Sebastian Morales commented on Aug 25, 2021

Which type of web server are you using, is it PHP built-in server, Apache, Nginx or something else?

George commented on Aug 26, 2021

Locally I'm running MAMP. PHP Version 7.4. On Prod we are running LAMP stack (Apache web server, running on Amazon Linux 2 OS).

The PHP warning shows up on both.

Sebastian Morales commented on Aug 27, 2021

Was there any pdf generated? If there was, did it have any issue?

In any case, pls try this export command:

$report->cloudExport("MyReportPDF")
    ->chromeHeadlessio($secretToken)
    ->settings([
        'useLocalTempFolder' => true, 
    ])
    ->pdf(...)
    ->saveAs(...)
    ;

Then run export and check subdirectory "tmp" in your report directory and look for its latest subdirectory's "export.html" file. Open "export.html" in your browser and let us know the result. 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
bug
help needed

CloudExport