Welcome Guest, Not a member yet? Register   Sign In
how to call class FPDF in CI4
#5

(11-06-2021, 03:58 PM)ghete Wrote: Hi guys .. please give some suggestion for my problem ..
i want to make some report using FPDF with CI4
 ==== it s my controller =====
<?php namespace App\Controllers;

use App\ThirdParty\FPDF;

public function laporan(){
$pdf=new UMUM('P','mm','Legal');

$pdf->SetMargins(5,7,5);
$pdf->SetAutoPageBreak(true,20);
$pdf->AliasNbPages('{pages}');
$pdf->AddPage();
$this->response->setHeader('Content-Type','application/pdf');


the problem is how to call class UMUM in CI 4  ... i tried it in CI 3 and it work but it doesn't work in CI 4

CI3 uses autoload by default, In CI4 you should show where use App\ThirdParty\FPDF; is located by name.
I solve this problem 
1) by going into App directory, 
2) if there none Create ThirdParty directory. 
3) then entered compose init, 
4) after some initialization entered by you enter  "composer require twig/twig" (as an example) 
once the composer sets up all the folders for you, 
5) download the FPDF zip file unzip to into vendor directory by the name fpdf
6) add the following  to the app\thirdparty\vendor\composer\autoload_psr4.php file
return array(
            ....
            ....
            'FPDF\\' => array($vendorDir . '/fpdf'),
);

or you can add the same thing into App\Config\Autoload.php file.. make sure you show the link of the file correctly.
Reply


Messages In This Thread
how to call class FPDF in CI4 - by ghete - 11-06-2021, 03:58 PM
RE: how to call class FPDF in CI4 - by ghete - 11-07-2021, 03:48 PM
RE: how to call class FPDF in CI4 - by nurmyrat - 12-27-2021, 06:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB