Class "PHPMailer\PHPMailer\PHPMailer" not found - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Class "PHPMailer\PHPMailer\PHPMailer" not found (/showthread.php?tid=82892) |
Class "PHPMailer\PHPMailer\PHPMailer" not found - mazz - 08-31-2022 I'm using CodeIgniter 4 and I'm trying add PHPMailer to my project via a composer: Quote:composer require phpmailer/phpmailer My Controller: PHP Code: <?php And I have this error: Quote:Class "PHPMailer\PHPMailer\PHPMailer" not found Where is a problem? RE: Class "PHPMailer\PHPMailer\PHPMailer" not found - captain-sensible - 08-31-2022 I use phpmailer and it works a treat. Structure of my app is : Code: [andrew@darkstar:/srv/http]$ tree -L 1 ads.com (08-31 15:08) /app/config/Autolaod.php is " Code: public $psr4 = [ And in controller to use it : Code: <?php namespace App\Controllers; structure of PHPMAiler directory is: Code: the classes for phpmailer are of course in source RE: Class "PHPMailer\PHPMailer\PHPMailer" not found - mazz - 08-31-2022 I added this to my app/Config/Autoload.php: PHP Code: 'PHPMailer\PHPMailer' => ROOTPATH . 'vendor/phpmailer/phpmailer/src' and it works! But I have one more question. Why you used '\\' (double) in below code? (08-31-2022, 07:12 AM)captain-sensible Wrote: RE: Class "PHPMailer\PHPMailer\PHPMailer" not found - captain-sensible - 08-31-2022 basically the first \ "escapes" the second - just a quirk of the way things work like "@" , " | " " \ " is a special character so there is a clash between implementation of what a special character does and use as namespace path. So by adding another \ it equates to literal use RE: Class "PHPMailer\PHPMailer\PHPMailer" not found - kenjis - 08-31-2022 It seems your code should work. Code: --- a/app/Controllers/Home.php There is no error: Code: $ php public/index.php RE: Class "PHPMailer\PHPMailer\PHPMailer" not found - captain-sensible - 09-18-2022 One thing that helps with debugging namespaces is to run from the web app : Code: [andrew@darkstar:http/kursaal2.org]$ php spark namespaces (09-18 10:36) helped me track down why it wasn't working in a new web |