@dean_007, Yes, it may have solved the error, but it is a bit crude…
I would do the following to better align with PHP PSR-1 codestyle, Composer autoloading and Grav itself:
- Create a plugin using
$ bin/plugin devtools newplugin
and name it ProductPDF
Judging from your code, it seems you’ve used this utility. $ cd user/plugins/product-pdf
$ composer require tecnickcom/tcpdf
Noterequire
instead ofrequired
- Create file /user/plugins/product-pdf/classes/MyPDF.pdf, with the following content:
Note the CamelCase naming convention for both the file and class.<?php namespace Grav\Plugin\ProductPDF; use TCPDF; class MyPDF extends TCPDF { public $logoPath; public $product; public $dxfIconPath; public $dxfFilePath; public function Header() { // Code } public function Footer() { // Code } }
- Make the following changes in file /user/plugins/product-pdf/product-pdf.php:
- Add
use Grav\Plugin\ProductPDF\MyPDF;
- Don’t use
require __DIR__ . '/vendor/autoload.php';
public function autoload()
will be called by Grav when plugin is initialized. - Remove
use TCPDF;
- Remove entire class MYPDF
- Replace
$pdf = new MYPDF(...)
with$pdf = new MyPDF(...)
- Add