controller类的render部分,用于渲染视图和布局文件: /** * Returns all ancestor modules of this controller. * 获取当前控制器所有的父模块 * The first module in the array is the outermost one (i.e., the application instance), * while the last is the innermost one. * @return Module[]…
今天开始阅读yii2的源码,想深入了解一下yii框架的工作原理,同时学习一下优秀的编码规范和风格.在此记录一下阅读中的小心得. 每个框架都有一个入口文件,首先从入口文件开始,yii2的入口文件位于web目录的index.php,用于启动web应用和配置一些路径参数. index.php—— // comment out the following two lines when deployed to production defined('YII_DEBUG') or define('YII_D…
接下来阅读BaseYii.php vendor/yiisoft/yii2/BaseYii.php—— namespace yii; use yii\base\InvalidConfigException; use yii\base\InvalidParamException; use yii\base\UnknownClassException; use yii\log\Logger; use yii\di\Container; 第1行定义命名空间为yii: 第3到7行使用了命名空间: /**…
web/Application类的注释,继承base/Application类,针对web应用的一些处理: namespace yii\web; use Yii; use yii\base\InvalidRouteException; /** * Application is the base class for all web application classes. * Application 是所有web应用的基类 * * @property string $homeUrl The hom…
Widget类中开始,获取视图对象,获取widget ID,渲染视图,获取路径方法注释: private $_id; /** * Returns the ID of the widget. * 返回插件的ID * @param boolean $autoGenerate whether to generate an ID if it is not set previously * @return string ID of the widget. */ public function getId(…