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

How to reference external files in Yii

尚
Original
2019-12-17 15:32:172556browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn