Skip to content

Cannot set path with spaces #170

@kAlvaro

Description

@kAlvaro

I want to parametrise the path to a command-line tool:

C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe

... with this test script:

<?php
require __DIR__ . '/vendor/autoload.php';

$dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->load();

var_dump($_ENV['WKHTMLTOPDF']);

... and this expected output:

string(50) "C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe"

As of v2.2.0 it's apparently not possible:

WKHTMLTOPDF=C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe

... triggers:

Dotenv values containing spaces must be surrounded by quotes.

WKHTMLTOPDF="C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe"

.... prints:

string(52) ""C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe""

WKHTMLTOPDF='C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe'

... prints:

string(52) "'C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe'"

Escaping spaces with \ (as in bash) triggers Dotenv values containing spaces must be surrounded by quotes as well.


Note: on Windows you can use short file names (if enabled) as a workaround:

WKHTMLTOPDF=C:\PROGRA~1\wkhtmltopdf\bin\wkhtmltopdf.exe

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions