1 year ago
#297074
projet senforage
Error Mailer : dependencies class using my autoload instead of composer class
im trying to use symfony/Mailer depencies with composer on my project , the problem i have my own autoload in my class but when i try to send a mail there is this error :
Warning: include(/Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/../src/Entities/Symfony\Component\Mailer\Bridge\Mailgun\Transport\MailgunTransportFactory.php): Failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/autoload.php on line 10
Warning: include(): Failed opening '/Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/../src/Entities/Symfony\Component\Mailer\Bridge\Mailgun\Transport\MailgunTransportFactory.php' for inclusion (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/autoload.php on line 10
Warning: include(/Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/../src/Entities/Symfony\Component\Mailer\Bridge\Mailjet\Transport\MailjetTransportFactory.php): Failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/autoload.php on line 10
Warning: include(): Failed opening '/Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/../src/Entities/Symfony\Component\Mailer\Bridge\Mailjet\Transport\MailjetTransportFactory.php' for inclusion (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/autoload.php on line 10
Warning: include(/Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/../src/Entities/Symfony\Component\Mailer\Bridge\Mailchimp\Transport\MandrillTransportFactory.php): Failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/autoload.php on line 10
Warning: include(): Failed opening '/Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/../src/Entities/Symfony\Component\Mailer\Bridge\Mailchimp\Transport\MandrillTransportFactory.php' for inclusion (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/autoload.php on line 10
Warning: include(/Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/../src/Entities/Symfony\Component\Mailer\Bridge\Postmark\Transport\PostmarkTransportFactory.php): Failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/autoload.php on line 10
Warning: include(): Failed opening '/Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/../src/Entities/Symfony\Component\Mailer\Bridge\Postmark\Transport\PostmarkTransportFactory.php' for inclusion (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/autoload.php on line 10
Warning: include(/Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/../src/Entities/Symfony\Component\Mailer\Bridge\Sendgrid\Transport\SendgridTransportFactory.php): Failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/autoload.php on line 10
Warning: include(): Failed opening '/Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/../src/Entities/Symfony\Component\Mailer\Bridge\Sendgrid\Transport\SendgridTransportFactory.php' for inclusion (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/autoload.php on line 10
Warning: include(/Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/../src/Entities/Symfony\Component\Mailer\Bridge\Sendinblue\Transport\SendinblueTransportFactory.php): Failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/autoload.php on line 10
Warning: include(): Failed opening '/Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/../src/Entities/Symfony\Component\Mailer\Bridge\Sendinblue\Transport\SendinblueTransportFactory.php' for inclusion (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/autoload.php on line 10
Warning: include(/Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/../src/Entities/Symfony\Component\Mailer\Bridge\OhMySmtp\Transport\OhMySmtpTransportFactory.php): Failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/autoload.php on line 10
Warning: include(): Failed opening '/Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/../src/Entities/Symfony\Component\Mailer\Bridge\OhMySmtp\Transport\OhMySmtpTransportFactory.php' for inclusion (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/autoload.php on line 10
Warning: include(/Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/../src/Entities/Symfony\Component\Mailer\Bridge\Amazon\Transport\SesTransportFactory.php): Failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/autoload.php on line 10
Warning: include(): Failed opening '/Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/../src/Entities/Symfony\Component\Mailer\Bridge\Amazon\Transport\SesTransportFactory.php' for inclusion (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/autoload.php on line 10
Warning: session_start(): Session cannot be started after headers have already been sent in /Applications/XAMPP/xamppfiles/htdocs/sen_forage/Youtech/Authentication.php on line 14
Warning: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/sen_forage/config/autoload.php:10) in /Applications/XAMPP/xamppfiles/htdocs/sen_forage/Youtech/entryPoint.php on line 62
the mail is sent with success but some of the of class are trying to use of Mailer dependencies are trying to load class using my loader. here is the code of my autoload
function autoloader($className)
{
$fileName = str_replace('\\', '/', $className) . '.php';
$file = __DIR__ . '/../' . $fileName;
if(!file_exists($file)){
$file = __DIR__ .'/../src/Entities/'.$className.'.php';
}
include $file;
}
spl_autoload_register('autoloader');
and the tree of my project i dont know if it will be need without the vendor of course but i run it with the vendor.
── Youtech
│ ├── Authentication.php
│ ├── EntryPoint.php
│ └── Routes.php
├── bootstrap.php
├── cli-config.php
├── composer.json
├── composer.lock
├── config
│ └── Autoload.php
├── public
│ ├── apache.access.log
│ ├── index.php
│ └── resources
│ ├── bootstrap
│ │ ├── css
│ │ │ ├── bootstrap-responsive.min.css
│ │ │ └── bootstrap.min.css
│ │ ├── img
│ │ │ ├── glyphicons-halflings-white.png
│ │ │ └── glyphicons-halflings.png
│ │ └── js
│ │ └── bootstrap.min.js
│ ├── css
│ │ └── theme.css
│ ├── font
│ │ ├── Amaranth-Bold.php
│ │ ├── Amaranth-Bold.z
│ │ ├── NotoSe.php
│ │ └── NotoSe.z
│ ├── images
│ │ ├── Blank Document.pdf
│ │ ├── bg.png
│ │ ├── icons
│ │ │ ├── css
│ │ │ │ └── font-awesome.css
│ │ │ └── font
│ │ │ ├── fontawesome-webfont3294.eot
│ │ │ ├── fontawesome-webfont3294.ttf
│ │ │ ├── fontawesome-webfont3294.woff
│ │ │ └── fontawesome-webfontd41d.eot
│ │ ├── img.jpg
│ │ ├── jquery-ui
│ │ │ └── picker.png
│ │ ├── logo.png
│ │ └── user.png
│ ├── index2.php
│ ├── scripts
│ │ ├── common.js
│ │ ├── datatables
│ │ │ └── jquery.dataTables.js
│ │ ├── flot
│ │ │ ├── jquery.flot.js
│ │ │ ├── jquery.flot.pie.js
│ │ │ └── jquery.flot.resize.js
│ │ ├── jquery-1.9.1.min.js
│ │ └── jquery-ui-1.10.1.custom.min.js
│ └── userimage
│ ├── user-1.jpeg
│ ├── user-2.jpeg
│ ├── user-3.jpeg
│ ├── user-4.jpeg
│ └── user-5.png
├── sen_forage_db.sql
├── src
│ ├── Entities
│ │ ├── Abonnement.php
│ │ ├── Attribution.php
│ │ ├── Compteur.php
│ │ ├── Consommation.php
│ │ ├── Facture.php
│ │ ├── Habitant.php
│ │ ├── Numero.php
│ │ ├── Reglement.php
│ │ ├── Role.php
│ │ ├── User.php
│ │ └── Village.php
│ ├── Forage
│ │ ├── Controller
│ │ │ ├── Abonnement.php
│ │ │ ├── Client.php
│ │ │ ├── Compteur.php
│ │ │ ├── Consommation.php
│ │ │ ├── Facture.php
│ │ │ ├── Forage.php
│ │ │ ├── Numero.php
│ │ │ ├── User.php
│ │ │ └── Village.php
│ │ └── ForageRoutes.php
│ └── Utility
│ ├── ChiffreEnLettres.php
│ └── Pdf.php
└── templates
├── abolist.html.php
├── abonnementcreate.html.php
├── addConso.html.php
├── admin.html.php
├── clientcreate.html.php
├── compteurlist.html.php
├── consommationsliste.html.php
├── empty.html.php
├── gestionnaireclientele.html.php
├── gestionnairecommercial.html.php
├── gestionnairecompteur.html.php
├── home.html.php
├── layout.html.php
├── listeclients.html.php
├── listefacture.html.php
├── listevillage.html.php
├── listuser.html.php
├── login.html.php
├── loginerror.html.php
├── navbar.html.php
├── newcpt.html.php
├── permissionerror.html.php
├── sommaireReglement.html.php
├── test.html.php
├── usercreate.html.php
└── villagecreate.html.php
and the index php where i use the mailer just for now .
<?php
use Symfony\Component\Mailer\Transport;
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mime\Email;
try {
include __DIR__ . '/../bootstrap.php';
include __DIR__ . '/../config/autoload.php';
$dsn = 'gmail+smtp://user:pass@default';
$transport = Transport::fromDsn($dsn);
$mailer = new Mailer($transport);
$email = (new Email())
->from('mail')
->to('mail')
->priority(Email::PRIORITY_HIGH)
->subject('Time for Symfony Mailer!')
->text('Sending emails is fun again!');
$mailer->send($email);
echo 'error';
http_response_code(301);
$route = ltrim(strtok($_SERVER['REQUEST_URI'], '?'), '/');
// echo password_hash('passer123',PASSWORD_DEFAULT);
$entryPoint = new \Youtech\entryPoint($route,new \src\Forage\ForageRoutes($entityManager),$_SERVER['REQUEST_METHOD']);
$entryPoint->run();
} catch (\Exception $e) {
$title = 'An error has occurred';
$output = 'Database error: ' . $e->getMessage() . ' in ' . $e->getFile() . ':' . $e->getLine();
}
php
dependencies
composer-php
autoload
symfony-mailer
0 Answers
Your Answer