我正在使用交响乐和苗条的音乐,因此我使用可以在控制器中调用的服务,然后使用细枝视图。我使用composer安装了Dompdf,并将其添加到我的bootstrap文件夹中的服务列表中。我尝试了几种调用dompdf的方法,但仍然得到
消息:找不到“ Dompdf”类
class SlipController extends \App\Controllers\Base\PageController{
function getHandler($request, $response, $args)
{
// Instantiate Dompdf with our options
$dompdf = new Dompdf();
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser (force download)
$dompdf->stream("mypdf.pdf", [
"Attachment" => true
]);
return $this->view->render($response,'pages/slips.twig');
}
<?php
$container['dompdf'] = function($container) {
return new \Dompdf\Dompdf;
};
答案 0 :(得分:1)
您是否在代码中添加了一条use语句?
Show (l a)