I am using a Laravel job which handles specific registration confirmations via mail.
In the handle()
function of the job I am referring to another class' static function (TicketController
) which generates a PDF:
public function handle()
{
$this->ticket = TicketController::createPdf($this->customer);
Mail::to($this->customer->email)->send(new CustomerAccepted($this->customer, $this->ticket));
}
If I run this job via sync
driver everything is just working fine. But with database
I always get the error
class 'PDFlib' not found
Of course the class is implemented in my TicketController
and I also tried implementing it directly into my job class.
I also tried restarting the queue worker several times but I always get the same result when running with database
.
EDIT:
TicketController.php
:
use App\Customer;
use PDFlib;
class TicketController extends Controller
{
public function createPdf(Customer $customer)
{
$p = new PDFlib();
$p->set_option("errorpolicy=return");
$p->set_option("stringformat=utf8");
$p->set_option("searchpath={" . resource_path() . "assets/fonts" . "}");
$p->set_option("spotcolorlookup=false");
if ($p->begin_document(storage_path('app/xy.pdf'), "") == 0) {
echo ("Error: " . $p->get_errmsg());
exit(1);
}
// Loading template and filling with content
$p->end_page_ext("");
$p->end_document("");
return storage_path('app/xy.pdf');
}
}
EDIT #2
I added the complete PDFlib
function directly to the handle()
of the job but still getting the same error class 'PDFlib' not found
.
EDIT #3
Just realized that running the driver database
locally and listen to queues with php artisan queue:listen
is working perfectly fine.
I am running the application on Laravel Forge and also database
driver. Tried to set up the queue with daemon worker and without but neither setting works.