Skip to content

Instantly share code, notes, and snippets.

@samirreza
Last active April 22, 2019 11:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samirreza/55ffde9822b2efdcff76f484d18f9322 to your computer and use it in GitHub Desktop.
Save samirreza/55ffde9822b2efdcff76f484d18f9322 to your computer and use it in GitHub Desktop.
define global constant.
register composer autoloader.
include Yii class file.
load application configuration.
creating application instance :
set Yii::$app.
call preInit :
confige high order properties like basePath.
register error handler.
configure other application properties.
call init from BaseObject :
calls bootstrap() to run bootstrapping components :
include the extension manifest file vendor/yiisoft/extensions.php.
create and run bootstrap components declared by extensions.
create and run application components and/or modules that are declared in the application's bootstrap property.
call run :
triger EVENT_BEFORE_REQUEST.
handle request :
resolve the request into a route and the associated parameters and create the module, controller, and action objects as specified by the route :
The yii\base\Controller::init() method is called after the controller is created and configured.
The controller creates an action object based on the requested action ID and if cant find action throw yii\base\InvalidRouteException exception.
triger EVENT_BEFORE_ACTION from application then triger EVENT_BEFORE_ACTION From module (if the controller belongs to a module) then triger EVENT_BEFORE_ACTION from controller.
The controller creates an action instance and performs the pre filters for the action with order of specifing filters (just beforeAction method call), first application filters then module filters then controller filters.
run action :
the action may loads a data model, possibly from a database.
the action renders a view, providing it with the data model :
triger EVENT_BEFORE_RENDER.
triger EVENT_BEGIN_PAGE.
triger EVENT_BEGIN_BODY.
triger EVENT_END_BODY.
triger EVENT_END_PAGE.
triger EVENT_AFTER_RENDER.
the controller performs the post filters for the action with reverse order of specifing filters (just afterAction method call), first controller filters then module filters then application filters.
triger EVENT_AFTER_ACTION from controller then triger EVENT_AFTER_ACTION From module (if the controller belongs to a module) then triger EVENT_AFTER_ACTION from applicatopn.
triger EVENT_AFTER_REQUEST.
send response to the end user :
trigger the yii\web\Response::EVENT_BEFORE_SEND event.
call yii\web\Response::prepare() to format response data into response content.
trigger the yii\web\Response::EVENT_AFTER_PREPARE event.
call yii\web\Response::sendHeaders() to send out the registered HTTP headers.
call yii\web\Response::sendContent() to send out the response body content.
trigger the yii\web\Response::EVENT_AFTER_SEND event.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment