开发者

Include Files in Yii

开发者 https://www.devze.com 2023-03-30 03:35 出处:网络
I am building an application in Yii that used the SwiftMailer Extension. The Sw开发者_Python百科iftMailer examples show that I should include all of the information in the controller file however woul

I am building an application in Yii that used the SwiftMailer Extension. The Sw开发者_Python百科iftMailer examples show that I should include all of the information in the controller file however would it not be more organized and better to put all of the information for the email in a seperate file and include that file?

If yes, what would be the best way to include that file? I am used to just using the include function but I am assuming with Yii it should be its own class under the components folder?


Ya, you probably want to make a custom class and put your SwiftMailer function in there, as well as any related functions, as appropriate. You can either put it in your components directory or a custom "classes" directory depending on how yo want to import it.

In that class, you can include the SwiftMailer libary (see here for an example of how), in your constructor function or similar.

0

精彩评论

暂无评论...
验证码 换一张
取 消