Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel Snappy抛出错误500,无进一步信息_Php_Laravel_Wkhtmltopdf_Snappy_Laravel Snappy - Fatal编程技术网

Php Laravel Snappy抛出错误500,无进一步信息

Php Laravel Snappy抛出错误500,无进一步信息,php,laravel,wkhtmltopdf,snappy,laravel-snappy,Php,Laravel,Wkhtmltopdf,Snappy,Laravel Snappy,我想使用barryvdh\laravel snappy创建PDF文件。我遵循了github页面上的所有步骤,但是每当我使用诸如 $pdf->output(); $pdf->下载(“test.pdf”); 我得到一个服务器错误 我尝试在windows上使用安装程序和编写器依赖项安装WKTHLTOPDF。我清除了缓存,使用了composer更新,dump autoload等等 这是我的控制器中的功能: 公共函数createInvoice($id) { $data=[“数据”=>“数据”]; $pd

我想使用barryvdh\laravel snappy创建PDF文件。我遵循了github页面上的所有步骤,但是每当我使用诸如

$pdf->output();
$pdf->下载(“test.pdf”);
我得到一个服务器错误

我尝试在windows上使用安装程序和编写器依赖项安装WKTHLTOPDF。我清除了缓存,使用了composer更新,dump autoload等等

这是我的控制器中的功能:

公共函数createInvoice($id)
{
$data=[“数据”=>“数据”];
$pdf=pdf::loadView(“invoice.default”,$data);
dd($pdf);
返回响应()->json([
“pdf”=>base64_编码($pdf->output())
]);
}
我的snappy.php配置:

'pdf'=>[
“已启用”=>true,
“binary”=>基本路径(“vendor/h4cc/wkhtmltopf-amd64/bin/wkhtmltopf-amd64”),
'timeout'=>false,
“选项”=>[],
“env”=>[],
],
“图像”=>[
“已启用”=>true,
“binary”=>基本路径('vendor/h4cc/wkhtmltoimage-amd64/bin/wkhtmltoimage-amd64'),
'timeout'=>false,
“选项”=>[],
“env”=>[],
],
My app.php配置:

“提供者”=>[
.
.
Barryvdh\Snappy\ServiceProvider::类,
.
.
.
“别名”=>[
.
.
'PDF'=>Barryvdh\Snappy\Facades\SnappyPdf::class,
“SnappyImage”=>Barryvdh\Snappy\Facades\SnappyImage::class,
在$pdf上使用dd时,在调用output、download、inline等函数之前,我会得到以下响应:

PdfWrapper {#347
  #snappy: IlluminateSnappyPdf {#346
    #optionsWithContentCheck: array:4 [
      "header-html" => "html"
      "footer-html" => "html"
      "cover" => "html"
      "xsl-style-sheet" => "xsl"
    ]
    -binary: "C:\xampp\htdocs\invoicing\vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64"
    -options: array:125 [
      "ignore-load-errors" => null
      "lowquality" => true
      "collate" => null
      "no-collate" => null
      "cookie-jar" => null
      "copies" => null
      "dpi" => null
      "extended-help" => null
      "grayscale" => null
      "help" => null
      "htmldoc" => null
      "image-dpi" => null
      "image-quality" => null
      "manpage" => null
      "margin-bottom" => null
      "margin-left" => null
      "margin-right" => null
      "margin-top" => null
      "orientation" => null
      "output-format" => null
      "page-height" => null
      "page-size" => null
      "page-width" => null
      "no-pdf-compression" => null
      "quiet" => null
      "read-args-from-stdin" => null
      "title" => null
      "use-xserver" => null
      "version" => null
      "dump-default-toc-xsl" => null
      "dump-outline" => null
      "outline" => null
      "no-outline" => null
      "outline-depth" => null
      "allow" => null
      "background" => null
      "no-background" => null
      "checkbox-checked-svg" => null
      "checkbox-svg" => null
      "cookie" => null
      "custom-header" => null
      "custom-header-propagation" => null
      "no-custom-header-propagation" => null
      "debug-javascript" => null
      "no-debug-javascript" => null
      "default-header" => null
      "encoding" => null
      "disable-external-links" => null
      "enable-external-links" => null
      "disable-forms" => null
      "enable-forms" => null
      "images" => null
      "no-images" => null
      "disable-internal-links" => null
      "enable-internal-links" => null
      "disable-javascript" => null
      "enable-javascript" => null
      "javascript-delay" => null
      "load-error-handling" => null
      "load-media-error-handling" => null
      "disable-local-file-access" => null
      "enable-local-file-access" => null
      "minimum-font-size" => null
      "exclude-from-outline" => null
      "include-in-outline" => null
      "page-offset" => null
      "password" => null
      "disable-plugins" => null
      "enable-plugins" => null
      "post" => null
      "post-file" => null
      "print-media-type" => null
      "no-print-media-type" => null
      "bypass-proxy-for" => null
      "proxy" => null
      "radiobutton-checked-svg" => null
      "radiobutton-svg" => null
      "run-script" => null
      "disable-smart-shrinking" => null
      "enable-smart-shrinking" => null
      "stop-slow-scripts" => null
      "no-stop-slow-scripts" => null
      "disable-toc-back-links" => null
      "enable-toc-back-links" => null
      "user-style-sheet" => null
      "username" => null
      "window-status" => null
      "zoom" => null
      "footer-center" => null
      "footer-font-name" => null
      "footer-font-size" => null
      "footer-html" => null
      "footer-left" => null
      "footer-line" => null
      "no-footer-line" => null
      "footer-right" => null
      "footer-spacing" => null
      "header-center" => null
      "header-font-name" => null
      "header-font-size" => null
      "header-html" => null
      "header-left" => null
      "header-line" => null
      "no-header-line" => null
      "header-right" => null
      "header-spacing" => null
      "replace" => null
      "disable-dotted-lines" => null
      "cover" => null
      "toc" => null
      "toc-depth" => null
      "toc-font-name" => null
      "toc-l1-font-size" => null
      "toc-header-text" => null
      "toc-header-font-name" => null
      "toc-header-font-size" => null
      "toc-level-indentation" => null
      "disable-toc-links" => null
      "toc-text-size-shrink" => null
      "xsl-style-sheet" => null
      "viewport-size" => null
      "redirect-delay" => null
      "cache-dir" => null
      "keep-relative-links" => null
      "resolve-relative-links" => null
    ]
    -env: null
    -timeout: false
    -defaultExtension: "pdf"
    #temporaryFolder: null
    +temporaryFiles: []
    -logger: NullLogger {#345}
    +"fs": Filesystem {#109}
  }
  #options: []
  +"html": """
    <!DOCTYPE html>
    <html>
    <head>
    \t<title>Invoice<title>
    </head>
    <body>
    <div class="container">
    \t<table class="table table-bordered">
    \t\t<thead>
    \t\t\t<th>Name</th>
    \t\t\t<th>Email</th>
    \t\t</thead>
    \t\t<tbody>
    \t\t\t<tr>
    \t\t\t\t<td>TEST</td>
    \t\t\t\t<td>BEST</td>
    \t\t\t</tr>
    \t\t</tbody>
    \t</table>
    </div>
    </body>
    </html>
    """
  +"file": null
}

将二进制路径更改为

  'pdf' => array(
        'enabled' => true,
        'binary'  => '/usr/local/bin/wkhtmltopdf', //for ubuntu
        // 'binary'  => '"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe"', //for windows
        'timeout' => false,
        'options' => array(),
        'env'     => array(),
    ),
    'image' => array(
        'enabled' => true,
        'binary'  => '/usr/local/bin/wkhtmltoimage', //for ubuntu
        // 'binary'  => '"C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe"', //for windows
        'timeout' => false,
        'options' => array(),
        'env'     => array(),
    ),

您已经为ubuntu设置了。

您正在使用哪个操作系统?Microsoft Windows 10。这解决了我的代码问题。当我使用真正的blade创建pdf时,我再次遇到同样的错误。在服务器中,您仍然需要使用基于服务器操作系统的二进制路径。您知道,为什么我在文件内容较多时出现服务器错误吗?@Commander不是因为有更多的内容,而是因为您试图使用的内容类型。@Commander似乎您需要给出该图像的正确路径,您使用的是错误的路径。
  'pdf' => array(
        'enabled' => true,
        'binary'  => '/usr/local/bin/wkhtmltopdf', //for ubuntu
        // 'binary'  => '"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe"', //for windows
        'timeout' => false,
        'options' => array(),
        'env'     => array(),
    ),
    'image' => array(
        'enabled' => true,
        'binary'  => '/usr/local/bin/wkhtmltoimage', //for ubuntu
        // 'binary'  => '"C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe"', //for windows
        'timeout' => false,
        'options' => array(),
        'env'     => array(),
    ),