View中的查找视图文件方法和渲染文件方法 /** * Finds the view file based on the given view name. * 通过view文件名查找view文件 * @param string $view the view name or the path alias of the view file. Please refer to [[render()]] * on how to specify this parameter. * @param string…
Action类,控制器中方法的基类: namespace yii\base; use Yii; /** * Action is the base class for all controller action classes. * Action是所有控制器方法的基类 * Action provides a way to reuse action method code. An action method in an Action * class can be used in multiple c…
Model类,集中整个应用的数据和业务逻辑——验证 /** * Returns the attribute labels. * 返回属性的标签 * * Attribute labels are mainly used for display purpose. For example, given an attribute * `firstName`, we can declare a label `First Name` which is more user-friendly and can *…
Model类,集中整个应用的数据和业务逻辑—— /** * Generates a user friendly attribute label based on the give attribute name. * 生成一个对用户友好的属性标签,将属性名中的下划线.破折号.点替换为空格,并且每个单词的首字母大写 * This is done by replacing underscores, dashes and dots with blanks and * changing the first…
Model类,集中整个应用的数据和业务逻辑——场景.属性和标签: /** * Returns a list of scenarios and the corresponding active attributes. * An active attribute is one that is subject to validation in the current scenario. * 返回所有场景及与之对应的 active 属性的列表 * active 属性是指在默认场景中验证的 * The r…
View中渲染view视图文件的前置和后置方法,以及渲染动态内容的方法: /** * @return string|boolean the view file currently being rendered. False if no view file is being rendered. */ public function getViewFile() { return end($this->_viewFiles);//返回[_viewFiles]中的最后一个view文件,即默认被渲染的文件…
今天开始阅读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…