简体   繁体   中英

pdftk: PHP Fatal error: Class 'mikehaertl\pdftk\Pdf' not found in

I have a project in Slim framework. There are multiple composer packages. Now, I have added https://github.com/mikehaertl/php-pdftk to fill PDF but I'm getting PHP Fatal error: Class 'mikehaertl\\pdftk\\Pdf' not found in... What is wrong with my code?

composer.json:

{
  "require": {
     "dibi/dibi": "^3.0",
     "slim/slim": "^3.7.0",
     "phpmailer/phpmailer": "^5.2",
     "jbroadway/urlify":"^1.1.0",
     "simplesoftwareio/simple-qrcode":"^1.5.1",
     "gopay/payments-sdk-php":"^1.2.3",
     "mikehaertl/php-pdftk":"^0.4.2"
   }
}

in my ./config/config.php there is:

 define('PATH', dirname(__DIR__));
 require_once PATH."/vendor/autoload.php";

and in my ./methods/controller.php:

 ...
 $pdf = new mikehaertl\pdftk\Pdf("/path/to/QR_template.pdf");
 ...

I tried to get names of all included files by using:

 var_dump(get_included_files());

but the "pdf" files were not in the array.

Other packages works well but pdftk not. Where is the problem?

Thank you.

Solved! The problem was composer version. Composer self-update solved the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM