Welcome Guest, Not a member yet? Register   Sign In
Use of FPDF library in CI4
#3

if you integrated seatsign/fpdf using composer, then to use the classes of that package in a controller it would be in the form of :

Code:
use  fullNamespaceName\classname   //Youwant to use

To get the namespace open up one of the classes with a text editor.
For instance i used composer to integrate PHPMailer into CI4

opening up one of the classes i saw they used the namespace
Code:
PHPMialer\PHPMailer

I noticed there were few classes , of which one class of PHPMailer might need to use another, so in my controller, where I will instantiate i wrote
Code:
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\OAuth;
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\SMTP;

then in the same controller to instantiate it was just :

Code:
$mail = new PHPMailer(true);

Now if you used composer to install , CI should know exactly where classes are , via autoload. So you should have to shift things about or mess with autoload class. Previously i manually put in PHPMailer at root level ; in that case I did have to make use of autoload.php and the section

Code:
public $psr4 = [
        APP_NAMESPACE => APPPATH, // For custom app namespace
        
        
        'Config'      => APPPATH . 'Config',
        'PHPMailer\\PHPMailer'=> ROOTPATH.'PHPMailer/src',
        
        
    ];

The point as i understand it is that with composer , if the classes integrated in vendor , DO HAVE a namespace in the classes, then you shouldn't have to do anything excpet make use of "use"
CMS CI4     I use Arch Linux by the way 

Reply


Messages In This Thread
Use of FPDF library in CI4 - by foxbille - 10-10-2022, 01:46 AM
RE: Use of FPDF library in CI4 - by ozornick - 10-10-2022, 01:59 AM
RE: Use of FPDF library in CI4 - by captain-sensible - 10-10-2022, 02:52 AM
RE: Use of FPDF library in CI4 - by foxbille - 10-10-2022, 08:49 AM
RE: Use of FPDF library in CI4 - by abatrans - 10-11-2022, 07:25 AM
RE: Use of FPDF library in CI4 - by DunogRamers - 11-04-2022, 11:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB