Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Anton Kril - MM15NL

7,099 views

Published on

Anton Kril on Magento 2 at Meet Magento 2015

Published in: Internet

Anton Kril - MM15NL

  1. 1. Anton Kril Magento 2 Request Flow • Magento • Architect, Magento 2 • @AntonKril
  2. 2. Warning • This presentation contains code • Code might be different from GitHub version • Some calls were omitted for simplification
  3. 3. Index.php EntryPoint::createApplication ObectManagerFactory::create Application::launch FrontController::dispatch Action::execute Magento Request Processing Flow
  4. 4. $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER); /** @var MagentoFrameworkAppHttp $app */ $app = $bootstrap->createApplication(MagentoFrameworkAppHttp::class); $bootstrap->run($app); Index.php EntryPoint::createApplication Application::launch FrontController::dispatch Action::execute ObectManagerFactory::create
  5. 5. INIT_PARAM_* constants Example: • MagentoFrameworkAppObjectManagerFactory::INIT_PARAM_DEPLOYMENT_CONFIG_FILE • MagentoFrameworkAppObjectManagerFactory::INIT_PARAM_DEPLOYMENT_CONFIG Index.php EntryPoint::createApplication Application::launch FrontController::dispatch Action::execute ObectManagerFactory::create
  6. 6. public function createApplication($type, $arguments) { $this->objectManager = $this->objectManagerFactory->create(); $application = $this->objectManager->create($type, $arguments); return $application; } Index.php EntryPoint::createApplication Application::launch FrontController::dispatch Action::execute ObectManagerFactory::create
  7. 7. Index.php EntryPoint::createApplication Application::launch FrontController::dispatch Action::execute ObectManagerFactory::create Lots of Stuf: • Read Deployment Config (env.php, config.php) • Create DI Definitions (Compiled VS Runtime) • Create Interception Infrastructure • Load Active Modules and Their global di.xml configuration
  8. 8. $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER); /** @var MagentoFrameworkAppHttp $app */ $app = $bootstrap->createApplication(MagentoFrameworkAppHttp::class); $bootstrap->run($app); Index.php EntryPoint::createApplication Application::launch FrontController::dispatch Action::execute ObectManagerFactory::create
  9. 9. Index.php EntryPoint::createApplication Application::launch FrontController::dispatch Action::execute ObectManagerFactory::create MagentoFrameworkAppInterface • Has nothing in common with Mage_Core_Model_App • We don’t have Mage_Core_Model_App • No Mage::app()->getWebsite() ->getConfig() • No Law of Demeter Violations
  10. 10. Index.php EntryPoint::createApplication Application::launch FrontController::dispatch Action::execute ObectManagerFactory::create public function launch() { $areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName()); $this->_state->setAreaCode($areaCode); $this->_objectManager->configure($this->_configLoader->load($areaCode)); $frontController = $this->_objectManager->get('MagentoFrameworkAppFrontControllerInterface'); $result = $frontController->dispatch($this->_request); $result->renderResult($this->_response); return $this->_response; }
  11. 11. Index.php EntryPoint::createApplication Application::launch FrontController::dispatch Action::execute ObectManagerFactory::create
  12. 12. Index.php EntryPoint::createApplication Application::launch FrontController::dispatch Action::execute ObectManagerFactory::create Front Controller Middleware: • Global • DB Version Check • Frontend • Varnish Request Processor • Base Url Check • Built-In Cache Request Processor • Message Box
  13. 13. Index.php EntryPoint::createApplication Application::launch FrontController::dispatch Action::execute ObectManagerFactory::create public function dispatch(RequestInterface $request) { foreach ($this->_routerList as $router) { $actionInstance = $router->match($request); if ($actionInstance) { $result = $actionInstance->dispatch($request); } } return $result; }
  14. 14. Index.php EntryPoint::createApplication Application::launch FrontController::dispatch Action::execute ObectManagerFactory::create Middleware: • Adminhtml • Authentication • Massaction • … • Frontend • CustomerGroup • StoreActivityCheck • …
  15. 15. Index.php EntryPoint::createApplication Application::launch FrontController::dispatch Action::execute ObectManagerFactory::create class Index extends MagentoFrameworkAppActionAction { public function execute() { $resultPage = $this->resultPageFactory->create(); return $resultPage; } }
  16. 16. Index.php EntryPoint::createApplication Application::launch FrontController::dispatch Action::execute ObectManagerFactory::create public function launch() { $areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName()); $this->_state->setAreaCode($areaCode); $this->_objectManager->configure($this->_configLoader->load($areaCode)); $frontController = $this->_objectManager->get('MagentoFrameworkAppFrontControllerInterface'); $result = $frontController->dispatch($this->_request); $result->renderResult($this->_response); return $this->_response; }
  17. 17. GET GET 200 GET ESI 200 200 GET Private Data 200 Page Cache
  18. 18. Page Cache
  19. 19. Summary • 8000 classes vs 2700 in Magento 1 • More customization points • Better area isolation (no overhead) • Better sub-system isolation (can be recomposed) • Rethought Page Caching

×