I have three libraries installed via composer.
https://github.com/barbushin/php-imap
https://github.com/PHPMailer/PHPMailer
https://github.com/openai-php/client
and I have tried to use it in my index.php file like
<?php
namespace PhpImap;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
.....
?>
Its giving me error on this line
$client = OpenAI::client($yourApiKey);
called
PHP Fatal error: Uncaught Error: Class "PhpImap\OpenAI" not found in /home/myuser/mydomain.com/dashboard/crons/reply/reply.php:216
My composer.json is like below
{
"config": {
"allow-plugins": {
"php-http/discovery": true
}
},
"require": {
"php-imap/php-imap": "^5.0",
"phpmailer/phpmailer": "^6.8",
"openai-php/client": "^0.6.4",
"symfony/http-client": "^6.3",
"nyholm/psr7": "^1.8"
}
}
If I remove Namespace PhpImap from 2nd line, its work but its required for my imap function. I think that namespace conflict with OpenAi library. I do not getting idea to resolve the issue. Let me know if someone can help me for solve the issue. Thanks!