forked from pi-engine/pi
-
Notifications
You must be signed in to change notification settings - Fork 0
Core.What Pi Do When Request Received
linzongshu edited this page Mar 11, 2015
·
12 revisions
- match
api/...
-> www/api.php - match
admin/...
-> www/admin.php - match
feed/...
-> www/feed.php - else -> www/index.php
What do these scripts do:
- Define engine class type
- Enabled boot, make it as request process other than Pi APIs pro
- Config var, lib, host path
- Define namespace
- Autoloader
- System configuration
- Code storage
- Bootstrap (Pi\Application\Engine\AbstractEngine)
- Services defined in configuration file
- Resources defined in configuration file
- Router Service (Zend\Mvc\Router\Http\TreeRouteStack)
- Initialize application instance
- ServiceManager
- EventManager
- Request
- Response
- Application boot (Zend\Mvc\Application)
- Attach listeners @see Attach Events
- MvcEvent
- Trigger EVENT_BOOTSTRAP
- Listeners
- RouteListener -> Zend\Mvc\RouteListener
- DispatchListener -> Zend\Mvc\DispatchListener
- ViewManager -> Zend\Mvc\View\Http\ViewManager
- SendResponseListener -> Zend\Mvc\SendResponseListener
- ViewStrategyListener -> Pi\Mvc\View\Http\ViewStrategyListener
- onBootstrap
- View service -> Zend\View\View
- Renderer service -> Zend\View\Renderer\PhpRenderer
- onRoute
- onDispatch
- Set controller instance, set controller EventManager
- Set controller MvcEvent
- Controller dispatch
- Trigger MVC Dispatch
- Call action method
- Trigger MVC Dispatch
- Trigger EVENT_DISPATCH_ERROR if error
- EVENT_BOOTSTRAP
- Pi\Mvc\View\Http\ViewStrategyListener::prepareRequestType() 99999
- Pi\Mvc\View\Http\ViewStrategyListener::prepareRootModel() 20000
- Zend\Mvc\View\Http\ViewManager::onBootstrap() 10000
- EVENT_ROUTE
- Pi\Mvc\View\Http\ViewStrategyListener::initThemeAssemble() 10000
- Zend\Mvc\RouteListener::onRoute()
- Pi\Mvc\View\Http\ViewStrategyListener::prepareActionResult() -99999
- EVENT_DISPATCH
- Pi\Application\Bootstrap\Resource\RenderCache::checkPage() 1000
- Pi\Application\Bootstrap\Resource\Module::setup() 999
- Pi\Application\Bootstrap\Resource\i18n::loadTranslator()
- Zend\Mvc\DispatchListener::onDispatch()
-
MVC EVENT_DISPATCH (trigger in
onDispatch()
)- Pi\Application\Bootstrap\Resource\Permission::checkAction() 99999
- Pi\Application\Bootstrap\Resource\RenderCache::checkAction() 999
- Pi\Mvc\Controller\ActionController::onDispatch()
- Pi\Mvc\View\Http\ViewStrategyListener::canonizeActionResult() -70
- Zend\Mvc\View\Http\CreateViewModelListener::createViewModelFromArray() -80
- Zend\Mvc\View\Http\CreateViewModelListener::createViewModelFromNull() -80
- Pi\Mvc\View\Http\ErrorStrategy::prepareErrorViewModel() -85
- Pi\Mvc\View\Http\ViewStrategyListener::injectTemplate() -89
- Zend\Mvc\View\Http\RouteNotFoundStrategy::prepareNotFoundViewModel -90
- Zend\Mvc\View\Http\InjectTemplateListener::injectTemplate() -90
- Pi\Application\Bootstrap\Resource\RenderCache::saveAction() -91
- Zend\Mvc\View\Http\InjectViewModelListener::injectViewModel() -100
- EVENT_DISPATCH_ERROR
- Zend\Mvc\View\Http\RouteNotFoundStrategy::detectNotFoundError()
- Zend\Mvc\View\Http\RouteNotFoundStrategy::prepareNotFoundViewModel()
- Zend\Mvc\View\Http\ExceptionStrategy::prepareExceptionViewModel()
- Zend\Mvc\View\Http\InjectViewModelListener::injectViewModel() -100
- EVENT_RENDER
- Pi\Mvc\View\Http\ViewStrategyListener::renderThemeAssemble() 10000
- Pi\Mvc\View\Http\ErrorStrategy::prepareErrorViewModel() 100
- Pi\Mvc\View\Http\ViewStrategyListener::canonizeErrorResult() 10
- Pi\Mvc\View\Http\ViewStrategyListener::canonizeThemeLayout() 5
- Zend\Mvc\View\Http\DefaultRenderingStrategy::render() -10000
-
RENDER VIEW EVENT: EVENT_RENDERER (trigger in
Zend\View\View::render()
)- Zend\View\Strategy\JsonStrategy::selectRenderer()
- Zend\View\Strategy\PhpRendererStrategy::selectRenderer()
-
RENDER VIEW EVENT: EVENT_RESPONSE
- Zend\View\Strategy\JsonStrategy::injectResponse()
- Zend\View\Strategy\PhpRendererStrategy::injectResponse()
- EVENT_RENDER_ERROR
- Pi\Mvc\View\Http\ViewStrategyListener::renderThemeAssemble() 10000
- Zend\Mvc\View\Http\ExceptionStrategy::prepareExceptionViewModel()
- Zend\Mvc\View\Http\InjectViewModelListener::injectViewModel() -100
- Zend\Mvc\View\Http\DefaultRenderingStrategy::render() -10000
- EVENT_FINISH
- Pi\Mvc\View\Http\ViewStrategyListener::completeThemeAssemble() 10000
- Pi\Application\Bootstrap\Resource\RenderCache::savePage() -9000
- Pi
-
$engine
-> Pi\Application\Engine\Standard (Pi.php)-
$application
-> Pi\Mvc\Application (Pi\Mvc\Application::load())$engine
-
$section
(string) -
$serviceManager
-> Zend\ServiceManager\ServiceManager (Zend\Mvc\Application::__construct()) -
$events
-> Zend\EventManager\EventManager (Zend\Mvc\Application::__construct())-
$sharedManager
-> Zend\EventManager\SharedEventManager (Zend\Mvc\Service\EventManagerFactory::createService()) -
$events
-> Event method
-
-
$request
-> Zend\Http\PhpEnvironment\Request-
$envParams
-> $_ENV (__construct()) -
$queryParams
-> $_GET -
$postParams
-> $_POST -
$fileParams
-> $_FILE -
$serverParams
-> $_SERVER -
$headers
-> Zend\Http\Headers
-
-
$response
-> Zend\Http\PhpEnvironment\Response -
$event
-> Zend\Mvc\MvcEvent (Zend\Mvc\Application::bootstrap())-
$target
-> Standard::$application -
$application
-> Standard::$application -
$request
-> Application::$request -
$response
-> Application::$response -
$router
-> Zend\Mvc\Router\Http\TreeRouteStack (Assign in bootstrap(), created in Resource\Router::boot())-
$routes
-> route data from db
-
-
-
-
- Application -> Pi\Mvc\Service\ApplicationFactory -> Pi\Mvc\Application
- Router -> Zend\Mvc\Router\Http\TreeRouteStack
- EventManager -> Zend\Mvc\Service\EventManagerFactory -> Zend\EventManager\EventManager
- Config -> Pi\Mvc\Service\Config
- RouteNotFoundStrategy -> Zend\Mvc\View\Http\RouteNotFoundStrategy
- ExceptionStrategy -> Zend\Mvc\View\Http\ExceptionStrategy
- DefaultRenderingStrategy -> Zend\Mvc\View\Http\DefaultRenderingStrategy
- View -> Zend\View\View
- ViewPhpRendererStrategy -> Zend\View\Strategy\PhpRendererStrategy
- ViewRenderer-> Zend\View\Renderer\PhpRenderer
- ViewHelperManager -> Pi\Mvc\Service\ViewHelperManager
- ViewResolver -> Zend\Mvc\Service\ViewResolverFactory -> Zend\View\Resolver\AggregateResolver
- Where to initialize header and footer
- EVENT_ROUTE -> initThemeAssemble() -> Pi\View\Helper\ThemeAssemble::initStrategy()
- Append head meta from config
- Append footscript from config
- Set global variables from config
- EVENT_ROUTE -> initThemeAssemble() -> Pi\View\Helper\ThemeAssemble::initStrategy()