dougutuo9879
2018-01-14 18:47
浏览 183

pdftk:PHP致命错误:找不到类'mikehaertl \ pdftk \ Pdf'

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.

图片转代码服务由CSDN问答提供 功能建议

我在Slim框架中有一个项目。 有多个作曲家包。 现在,我添加了 https://github.com/mikehaertl/php-pdftk 来填写 PDF但是我收到PHP致命错误:找不到类'mikehaertl \ pdftk \ Pdf'...我的代码出了什么问题?

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 我的./config/config.php有:

  define('PATH',dirname(__ DIR __)); 
 require_once PATH。“/ vendor / autoload.php”  ; 
   
 
 

和我的./methods/controller.php:

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

我试图获取所有包含的名称 文件使用:

  var_dump(get_included  _files()); 
   
 
 

但“pdf”文件不在数组中。

其他包效果很好但是 pdftk没有。 问题出在哪里?

谢谢。

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doulu8537 2018-01-14 19:42

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

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题