亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

php - TP3.2 problem loading third-party libraries
黃舟
黃舟 2017-06-27 09:17:46
0
1
1064

Third-party libraries are often used in thinkphp development. I usually put the third-party class libraries in the Application/Codebase/ directory. Because many third-party libraries do not have namespaces, I don't want to add namespaces one by one. How to load the class library file in the Codebase directory?
For example, my tp project directory structure

I want to load the class.phpmailer.php file (without namespace) under CodebasephpMailer. What should I do? It is best to load it automatically.
I read the manual to use class library mapping. I created a new alias.php in commonconf, the code is as follows

return array(    
    'Codebase\phpMailer'        =>    APP_PATH.'/Codebase/phpMailer/class.phpmailer.php',    
    );

Then I $obj=new CodebasephpMailerPHPMailer();

in indexcontroller

Error: Class 'CodebasephpMailerPHPMailer' not found
How to deal with it? There is another question. The class loading error message in TP usually shows this error. How do I know which file it is looking for the class in? I can’t see the specific path information, so it is difficult to troubleshoot.

黃舟
黃舟

人生最曼妙的風(fēng)景,竟是內(nèi)心的淡定與從容!

reply all(1)
typecho
在引入的文件中加個(gè)命名空間
namespace Codebase\Phpmailer;

使用的時(shí)候就
use Codebase\Phpmailer\Phpmailer;

請(qǐng)注意你的首字母大小寫,以及不是class.phpmailer.php,而是Phpmailer.class.php
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template