cwebapplication.php,yii framework 运行流程

这篇博客详细解析了Yii框架中Web应用程序的生命周期,从`Yii::createWebApplication()`开始,涵盖`CWebApplication`的初始化、配置加载、组件注册、请求处理到视图渲染等关键步骤。深入理解这些过程对于优化和调试Yii应用至关重要。
摘要由CSDN通过智能技术生成

//Yii::createWebApplication( $config )->run(); yii extends yiibase index.php; yii.php -> yiibase.php;

// yiibase::createWebApplication; CWebApplication extends CApplication extends CModule extends CComponent

// f/web/CWebApplication.php f/base/CApplication.php f/base/CModule.php f/base/CComponent.php

//

// CApplication->_construct() ..> CWebApplication

// YiiBase::setApplication

// require p/config/main.php

// require p/config/params.php

// CApplication->setBasePath()

// CApplication->getBasePath()

// YiiBase::setPathOfAlias()

// CApplication->getBasePath()

// YiiBase::setPathOfAlias()

// CApplication->initSystemHandlers()

// CApplication->registerCoreComponents()

// CModule->configure()

// CComponent->attachBehaviors()

// CModule->preloadComponents()

// CWebApplication->init()

// CModule->init()

// CApplication->getRequest()

// CModule->getComponent()

// YiiBase::createComponent()

// CHttpRequest->init()

//

// CApplication->run()

// CComponent->hasEventHandle()

//

//

//

//

//

//

//

//

//

Yii::createWebApplication( $config )->run();

Yii yii.php ->yiibase.php

YiiBase::CWebApplication( $config )->run();

CWebApplication ..> CApplication()->run(); //index.php Yii::createWebApplication( $config )->run();

CWebApplication->processRequest()

CWebApplication->runController( $route );

CController->run()

CController->createAction()

CController->runActionWithFilers()

CFilterChain->run()

CInlineFilter->filter()

CController->filterAccessControl()

CFilter->filter()

CFilterChain-run()

CController->runAction()

CInlineAction->runWithParams()

PostController->actionIndex()

CController->render()

CController->renderPartial()

CBaseController->renderFile()

CBaseController->renderInternal()

require p/views/post/index.php // ...........>

CBaseController->widget()

CBaseListView->run()

CBaseListView->renderContent()

preg_replace_callback()

CBaseListView->renderSection()

CListView->renderltems()

CBaseController->renderFile()

CBaseController->renderInternal()

require p/views/post/_view.php // ........>

$data //... post object orm

# main

# Yii::createWebApplication( $config )

# CApplication->__construct()

# Yii::setApplication($this); // 将 CWebApplication 对像注册到 Yii::app();

# Yii::setPathOfAlias( 'application', $this->getBasePath()) // 当前应用路径

# Yii::setPathOfAlias( 'webroot', dirname($_SERVER['SCRIPT_FILENAME'])); // web根路径

# Yii::setPathOfAlias('ext',$this->getBasePath().DIRECTORY_SEPARATOR.'extensions'); ext 路径

# CModule->preinit();

# CApplication->initSystemHandlers() // 设置错误 handler

# CWebApplication->registerCoreComponents() 注册核心组件

# CApplication->registerCoreComponents() 注册核心组件

# CModule->setComPonents()

# CModule->setComponent()

# CModule->configure() Configures the module with the specified configuration.

# CComponent->_set()

# CComponent->attachBehaviors()

# CModule->preloadComponents() // config['preload'] => ['log']

# CWebApplication->init();

# CApplication->getRequest()

# CModule->getComponent('getRequest')

#

#

#

#

#

# CwebApplication->run();

# CComponent->hasEventHandler()

# php::register_shutdown_function( [$this,'end'],0,false)

# CWebApplication->processRequest() // 开始运行

# this->geturlManager()->parseurl($this->request());

# CWebApplication->runController($route)

# CWebApplication->createController()

# CController->run()

# CController->createAction()

# $this->runActionWithFilters(inlineaction,sitecontroller->filters());

# CFilterChain::create($this,$action,$filters)->run();

# CInlineFilter->filter()

# CController->filterAccessControl()

# CAccessControlFilter->setRules()

# CAccessControlFilter->filter()

# CAccessControlFilter->preFilter()

# CFilterChain->run()

# CController->runAction()

# CInlineAction->runWithParams()

# UserController->actionIndex()

#

#

#

#

#

# CComponent->hasEventHandler('onEndRequest') // 结束

# CApplication->onEndRequest()

# CComponent->raiseEvent()

# CList->getlterator()

# log

#

#

#

#Yii -> YiiBase -> createWebApplication

#CWebApplication -> CApplication -> CModule -> CComponent

#siteController -> Controller -> CController -> CBaseController -> CComponent

#LimitAppModel -> CActiveRecord -> CModel -> CComponent ->I IteratorAggregate, ArrayAccess

#

#View layouts -> main -> column -> site/index.php

9311376559308.jpg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值