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.
require_once($yii); $app = Yii::createWebApplication($config); Yii::$classMap = array( 'JPhpMailer' => Yii::getPathOfAlias('ext') . '/phpmailer/JPhpMailer.php', ); $app->run(); // 使用的时候可以不用再通过Yii::import()去引入文件。 $mailer = new JPhpMailer();
I hope this article will be helpful to everyone’s PHP programming based on the Yii framework.