basePath" method in the Yii code to reference external files."/> basePath" method in the Yii code to reference external files.">
Home > Article > PHP Framework > How to reference external files in Yii
Methods to reference files in Yii:
1, Yii::import("application.lib.PHPExcel.*");
Explanation:
application is equivalent to the protected folder.
2. In Yii’s ../config/main.php, introduce the base path
return array( 'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..', ...... // autoloading model and component classes 'import'=>array( 'application.models.*', 'application.components.*', 'application.helpers.*', // helper methods 'ext.mail.Message', 'application.lib.*', ), )
You can use the following method to reference in the code
Yii::app()->basePath
PHP Chinese website, There are a large number of free Yii introductory tutorials, everyone is welcome to learn!
The above is the detailed content of How to reference external files in Yii. For more information, please follow other related articles on the PHP Chinese website!