Class "PHPMailer\PHPMailer\PHPMailer" not found |
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?
08-31-2022, 07:12 AM
(This post was last modified: 08-31-2022, 07:16 AM by captain-sensible. Edit Reason: extra added )
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
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:
08-31-2022, 08:20 AM
(This post was last modified: 09-01-2022, 01:56 AM by captain-sensible. Edit Reason: elaboration of special charaxcter )
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
It seems your code should work.
Code: --- a/app/Controllers/Home.php There is no error: Code: $ php public/index.php
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 |
Welcome Guest, Not a member yet? Register Sign In |