I have a problem with my path. I am on windows, I want to use shell_exec to create pdf files.

This one doesn't work.

$cmd = 'wkhtmltopdf --cookie PHPSESSID q76abf3752tvttqds9qid1ca54 --print-media-type "http://localhost/al60/index.php?id=46&contr=dealer&event=loanrequests_details" "C:\Users\Bapt\AppData\Local\Temp/download_pdf_1381962017.pdf"';
$output = shell_exec($cmd);

This one works.

$cmd = '"c:\Program Files (x86)\wkhtmltopdf\wkhtmltopdf.exe" --cookie PHPSESSID q76abf3752tvttqds9qid1ca54 --print-media-type "http://localhost/al60/index.php?id=46&contr=dealer&event=loanrequests_details" "C:\Users\Bapt\AppData\Local\Temp/download_pdf_1381962017.pdf"';
$output = shell_exec($cmd);

I don't want to set the path of my executable, because it will have to run on other computers (including linux), I just want to use the name and let the OS resolve the path as it does in a command line. I have my path environment set up correctly for all user in my windows machine.

Thank you for your help.

有帮助吗?

解决方案

after thinking, I decided to echo the path

$output = shell_exec('echo %Path%');
$logger->log($output);

And the path to wkhtmltopdf, that I have added was not there. So I restarted apache, and it didn't work, so I restarted windows and it worked.

The good old restart :)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top