This article describes the example of Yii's method of automatically loading class maps. Share it with everyone for your reference. The details are as follows:
$classMap, a static attribute inherited by Yii, can be used for Yii's automatic loading of class maps. The key in the array is the class name, and the value in the array is the path to the corresponding class file.
4 |
require_once($yii);
$app = Yii::createWebApplication($config);
Yii::$classMap = array(
'JPhpMailer' => Yii::getPathOfAlias('ext') .
'/phpmailer/JPhpMailer.php',
);
$app->run();
// You don’t need to import files through Yii::import() when using it.
$mailer = new JPhpMailer();
|