【问题标题】:The exit status code '1' says something went wrong: stderr: "'C:\Program' is not recognized as an internal command or ... "退出状态代码“1”表示出了点问题:stderr:“'C:\Program' 未被识别为内部命令或......”
【发布时间】:2019-09-26 08:53:04
【问题描述】:

我得到了这个:

> The exit status code '1' says something went wrong:
stderr: "'C:\Program' is not recognized as an internal command
or external, an executable program or a batch file."

我在laravel下使用wkhtmltopdf生成pdf,效果很好。我将 windows 用于本地项目。现在,当我尝试生成它时,我收到了这个错误。没有任何变化,laravel 更新了,只是我不小心删除了我的 .env 文件。 我创建了一个新页面,但要么我的所有项目都得到一个完全空白的页面,要么在我执行 ajax 请求以生成 pdf 时出现此错误。

我在 .env 中尝试(通过 phpdotenv 3):

WKHTMLTOPDF='"C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf"'

配置/snappy.php:

<?php

return array(


    'pdf' => array(
        'enabled' => true,
        'binary'  => env('WKHTMLTOPDF'),
        'timeout' => false,
        'options' => array(),
        'env'     => array(),
    ),
    'image' => array(
        'enabled' => true,
        'binary'  => env('WKHTMLTOIMAGE'),
        'timeout' => false,
        'options' => array(),
        'env'     => array(),
    ),

    'binary' => env('WKHTMLTOPDF'),
);

【问题讨论】:

  • 你能把你的config/snappy.php文件代码贴在这里吗?
  • '"C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf"'"\"C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf\"",见php.net/manual/en/language.types.string.php
  • config/snappy.php 添加。这是我多次编辑后的最后一个版本
  • @JosefZ yes ` '"C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf"' ` 当我放入 snappy.php 时有效。但是,如果我想放入 .env 最好的语法是什么?

标签: windows laravel laravel-5 environment-variables wkhtmltopdf


【解决方案1】:

在你的 wkhtmltopdf bin 路径中转义你的空间

试试这个:

WKHTMLTOPDF='"C:\\Program\ Files\\wkhtmltopdf\\bin\\wkhtmltopdf"'

【讨论】:

    【解决方案2】:

    试试

    WKHTML_PDF_BINARY="\"\"C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe\"\""
    WKHTML_IMG_BINARY="\"\"C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe\"\""
    

    对我有用

    【讨论】:

      【解决方案3】:

      简单的做

      WKHTMLTOPDF="C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf"

      这对我有用。

      【讨论】:

      • 你使用的是 phpdotev 3 吗?如果没有,这是正常的。我的问题是 phpdotenv 3
      猜你喜欢
      • 2016-04-03
      • 1970-01-01
      • 2016-11-29
      • 2020-08-30
      • 2023-03-11
      • 2016-07-11
      • 1970-01-01
      • 2021-02-24
      • 1970-01-01
      相关资源
      最近更新 更多