1
votes

I'm setting up laravel-snappy to create pdf.

My snappy config is as below

<?php
return array(
'pdf' => array(
        'enabled' => true,
        'binary' => base_path('vendor/h4cc/wkhtmltopdf/bin/wkhtmltopdf'),
...

By running config('snappy') inside tinker, I also get the exact required path that is within the laravel project folder

But I'm getting the following error

local.ERROR: is_dir(): open_basedir restriction in effect. File(/tmp) is not within the allowed path(s):

How can I solve this without changing the php settings?

1
The binary is trying to write to the /tmp directory without permission.Dan
So, how can I set a tmp path within laravel?Selvin

1 Answers

0
votes

It seems like the package tries to write to the /tmp folder but is restricted through PHPs ini option open_basedir.

You can change this folder path to something within your application, maybe storage/tmp, with the setTemporaryFolder() method.

$pdf = App::make('snappy.pdf.wrapper');
$pdf->setTemporaryFolder(storage_path('tmp'));
// ...