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[]…
Caddy源码阅读(二)启动流程与 Event 事件通知 Preface Caddy 是 Go 语言构建的轻量配置化服务器.https://github.com/caddyserver/caddy Caddy 整个软件可以说是由不同的 插件 堆砌起来的.自己本身仅提供 Plugin 的注册运行逻辑和 Server 的监听服务功能. 学习 caddy 的源码,实际上是学习 如何构建一个 松耦合的 抽象 Plugin 设计,即模块化插拔的做法. 所以我们的源码阅读,围绕 Caddy 为 Plugin…
Yii2请求处理流程: 首先:项目路径/web/index.php (new yii\web\Application($config))->run();//根据配置文件创建App实例,先实例化yii\web\Application(),然后调用run()方法 该语句可分为两步: $application = new yii\web\Application($config);//实例化app $application->run();//调用run()方法 $config 为配置文件,通过 req…
今天开始阅读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…
wsgi.py----第二部分 pop_path_info()函数 先测试一下这个函数的作用: >>> from werkzeug.wsgi import pop_path_info >>> env = {'SCRIPT_NAME': '/foo', 'PATH_INFO': '/a/b'} >>> pop_path_info(env) 'a' >>> env['SCRIPT_NAME'] '/foo/a' >>>…
因为第一部分是关于初始化的部分的,我就没有发布出来~ wsgi.py----第一部分 在分析这个模块之前, 需要了解一下WSGI, 大致了解了之后再继续~ get_current_url()函数 很明显,该函数的作用是获取当前url地址. 代码如下: def get_current_url(environ, root_only=False, strip_querystring=False, host_only=False, trusted_hosts=None): """ :…
​ Trainer解析 我们继续Detectron2代码阅读笔记-(一)中的内容. 上图画出了detectron2文件夹中的三个子文件夹(tools,config,engine)之间的关系.那么剩下的文件夹又是如何起作用的呢? def main(args): cfg = setup(args) if args.eval_only: ... trainer = Trainer(cfg) trainer.resume_or_load(resume=args.resume) if cfg.TEST.A…
接下来阅读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(…