Yii2 DI singleton


I have been working with Yii2 with the past seven year now and after moving to a different company I’m mostly developing in SB3 instead of Yii2. However for some personal projects I still have Yii2 software kicking around and decided to finally give them some needed TLC. Currently I’m in the progress of moving them over from Swiftmailer to Symfony mailer and implementing DI instead of the Yii:$app->… implementation that are used everywhere.

I have hit a little snag: I have replaced my configuration with the proper configuration new yii\symfonymailer\Mailer class and updated the transport configuration. After these modification I’m able to send emails as aspected. After this first step I decided to update my base mailer class to using DI instead of the Yii::$app->mailer reference. When I made these changes I get a error from the Symfonymailer class ‘No transport was configured’. Using the documentation I found the container => singletons option and added the mailer in the array list. However the message still persist, from what I can getter the error is due to the fix that DI creates a new instance every time. I want it to use the mailer instance from the components list.
I would really like to know what I have done wrong :slight_smile:


Without relevant code, your answer will probably go unanswered. When asking questions, Please make sure to include relevant code and stack traces, removing only sensitive data