I'm trying to use PHPMailer through composer.
I'm using namespace and PSR-4 autoloading for my app
My file organisation is like this
-bin
-controllers
- Controller.php (namespace bin\controllers)
-vendor
-phpmailer
-phpmailer
-src
PHPMailer.php (namespace HPMailer\PHPMailer)
In composer.json, I wrote this
"autoload": {
"psr-4": {"bin\\vendor\\phpmailer\\": "bin/vendor/phpmailer/phpmailer/src/PHPMailer.php"}
}
But when I use
<?php
namespace bin\controllers;
use bin\vendor\phpmailer\PHPMailer;
abstract class Controller {
public function __construct()
{
$mail = new PHPMailer();
}
}
I got a fatal error :
require_once(): Failed opening required '/Users/thomas/Library/Mobile Documents/com~apple~CloudDocs/saveProject/bin/../bin/vendor/phpmailer/PHPMailer.php'
How I could configure the namespace to use the class correctly?
Thanks a lot in advance.