Home > Backend Development > PHP Tutorial > Yii source code interpretation-class automatic loading

Yii source code interpretation-class automatic loading

WBOY
Release: 2016-07-29 08:58:02
Original
936 people have browsed it

To implement

Yii’s automatic class loading, it relies on PHP’s spl_autoload_register(). Register an own autoloading function (autoloader) and insert it into the front of the autoloading function stack to ensure that Yii’s autoloader will be loaded first. transfer.

require(__DIR__ . '/../../vendor/autoload.php');

require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');

First load the third-party autoloader, and then load Yii's autoloader.

Last load Yii's autoloader, which ensures that Yii is loaded first.

Yii.php can view the call of the autoloader code, which registers BaseYii::autoload() as an autoloader.

The classes.php called in it contains all core classes.

Reference

  1. http://www.digpage.com/autoload.html

The above introduces Yii source code interpretation - automatic class loading, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template