SlideShare ist ein Scribd-Unternehmen logo
1 von 43
What’s really under
     the hood?
How I learned to stop worrying and love Magento
Who am I?
• Alan Storm
• http://alanstorm.com
• Got involved in The Internet/Web 1995
• Work in the Agency/Startup Space
• 10 years php experience
• The thing you can never say ...
Not a Computer Scientist
 • Many developers and programmers aren’t
 • You don't need to be a computer scientist
   to work with Magento
 • Magento is similar to PHP Frameworks
   (Cake, CodeIgniter, Kohana), just deeper
 • Magento and Kohana, side by side
 • But first
How We Got Here
 A Brief History of Web Development
HTML Page
HTML Page

• Very radical shift
• No programming needed, just markup
• No proprietary file format, just ASCII text
• Limited interactivity, SSIs
“Scripting” vs.
  “Real Programming"
• HTML included markup for form elements
• Stealth runtime, with client/server approach
• “Real Programmers” could do everything in
  C, C++, Java, lisp
• “Scripters” could piggy back on the web
  server for HTTP and produce HTML
Perl/CGI
• Perl was once the new hotness
• Excelled as string processing, and Web
  applications are strings over HTTP
• CPAN meant a shared code library
• Non-complied meant distributed programs
  were shared in the open
Perl/CGI

• CGI was slow, and FastCGI too new
• Perl didn't scale way before ruby didn't
• CPAN’s good but no standard library for
  the growing shared hosting ecosystem
PHP3/PHP4
• Looks like Perl! Sort of.
• Build important features directly into
  language, distributed by default
• Could import C code as extensions
• The build-up/tear-down approach of
  mod_php ideal for shared hosts
PHP Page
Rise of PHP Systems
• Created to combat PHP Applications
  becoming too complex/messy
• Shopping Cart Applications
• CMS systems (Drupal, Mambo, Joomla)
• Programming Frameworks, many inspired
  by Ruby on Rails (CakePHP, Code Igniter,
  Symfony)
Magento is the Next
  Evolutionary Step
• Is a shopping cart application
• Uses a module based approach to load new
  code into the system, similar to Drupal
• Implements a configuration based MVC
• Most PHP Frameworks are convention
  based, Magento is configuration based
Controllers and
           Routing
A Web MVC Router transforms the request URL into a
 controller class name and decides which method on
           that controller is the entry point
Kohana Routing

• Routing handled by Router_Core::setup
• URI: /controllerName/actionName
• URI: /welcome/index
• Welcome_Controller::index();
• File: /application/controllers/welcome.php
Magento Routing

• URI: /frontName/controllerName/actionName
• URI: /catalogsearch/result/index
• No Standard Router!
Magento Routing
• Magento Searches Global Config for
  routers
 • web/routers
• Default system ships with two Routers
 •   Mage_Core_Controller_Varien_Router_Admin

 •   Mage_Core_Controller_Varien_Router_Standard

• Configured in Mage_Core
Magento Routing

• The match method is called on each router
• The match method is responsible for
 • Creating a Controller class
 • Creating an Action method
 • Calling the Action method
Magento Routing
• URI: /frontName/controllerName/actionName
• URI: /catalogsearch/result/index
• Default routers will
 • Gather any module with a configured
   <frontName>catalogsearch</frontName>

 • Check modules controllers folder for a
   Packagename_Modulename_ControllerName
    Mage_CatalogSearch_ResultController
Magento Routing
• /frontName/controllerName/actionName
• /catalogsearch/result/index
• If a Controller is found, Router checks if for
  an action.
  •   Mage_CatalogSearch_ResultController::indexAction

• If action is found, it’s called, and the module
  search and match search stops.
Magento Routing
• Most of the time in a fresh install
 • /catalogsearch/result/index
 • translates to
   • Module: Mage_CatalogSearch
   • Controller: ResultController
   • Action: indexAction
Magento Routing
• Possible to Add Additional Routers through
  event system
 •   controller_front_init_routers

• See
 •   Mage_Cms_Controller_Router::initControllerRouters

 •   Sets up Mage_Cms_Controller_Router with different
     match rules
Front Controller

                            Mage_Core_Controller_Varien_Router_Admin

 Looks at Global Config
and Instantiates Routers

                           Mage_Core_Controller_Varien_Router_Standard

  Goes through each
Router and calls match()                      match()
  until a controller is
      dispatched
                                      Builds a list of Moules
                                     with matching frontName


                                     Check each module until
                                     it finds a valid controller/
                                             action pair
Models
Getting out of the SQL Writing Business
Kohana Models

• Extend from Base ORM class
• Mostly follows Active Record Pattern
 • Create, Read, Update, Delete
• Simple Class Instantiation
Magento Models
• Most Complex Models implement an Entity
  Attribute Value store
• Simpler “basic” models offers Active
  Record like functionality
• Implement a Mapper pattern, making Model
  independant of data store
• Client Programmer doesn’t need to know
  these details to use.
Magento Models
• Magento Replaces direction instantiation
     with a indirect static method call
 •    $user = new User();

 •    $customer = Mage::getModel(‘cusotmer/customer’);


• Every model has a Collection object which is
     used when fetching for multiple models.
     Kohana and other frameworks, return PHP
     arrays()
Views
It all comes back to HTML
Kohana View
                           Controller


Contrller Interacts with                Controller Picks specific
Model based on request                  variables to send to view




     Model                                    View
Kohana View

• Traditional PHP MVC View Pattern
• Views are PHP mixed with HTML
• Often called “Dumb View”, since the View
  doesn’t know anything about the Application
Magento View
                             Controller


Contrller Interacts with                              Controller Tells
Model based on request                                View to Kick Off




     Model                                               View
                           View Reads Data Directly
                              from Model Objects
Controller


Contrller Interacts with                              Controller Tells
Model based on request                                View to Kick Off




     Model                                               View
                           View Reads Data Directly
                              from Model Objects
Controller


Contrller Interacts with                Controller Tells
Model based on request                  View to Kick Off


                                                Layout is a nested collection
                                               of recursively rendering blocks


     Model                               Layout

                                          Root Block


                                                   Block

                                                   Block
     Blocks Read
     Data Directly
      from Model                                   Block
        Objects
                                                           Block

                                                   Block
Magento Block
• The simplest block is just a PHP class with
  a toHtml(), which returns a string
• Many Blocks render via a phtml template
• From within a phtml template, $this is a
  reference to the containing Block
• The phtml templates contain HTML and
  PHP code for rendering logic
• Block methods communicate with Models
Block Class




Template for Block
                     Templates may be set
                     programmatically or via
                     the Layout XML files
What’s really under
     the hood?
How I learned to stop worrying and love Magento

Weitere ähnliche Inhalte

Andere mochten auch

2017 Social Media & Content Marketing Predictions from 70 Marketing Leaders
2017 Social Media & Content Marketing Predictions from 70 Marketing Leaders 2017 Social Media & Content Marketing Predictions from 70 Marketing Leaders
2017 Social Media & Content Marketing Predictions from 70 Marketing Leaders Bryan Kramer
 
Omnichannel Customer Experience
Omnichannel Customer ExperienceOmnichannel Customer Experience
Omnichannel Customer ExperienceDivante
 
E-commerce Trends from 2015 to 2016 by Divante
E-commerce Trends from 2015 to 2016 by DivanteE-commerce Trends from 2015 to 2016 by Divante
E-commerce Trends from 2015 to 2016 by DivanteDivante
 
Digital marketing Trends 2017
Digital marketing Trends 2017Digital marketing Trends 2017
Digital marketing Trends 2017Infocrest
 
SEO for Ecommerce: A Comprehensive Guide
SEO for Ecommerce: A Comprehensive GuideSEO for Ecommerce: A Comprehensive Guide
SEO for Ecommerce: A Comprehensive GuideAdam Audette
 
Digital Marketing Trends 2017
Digital Marketing Trends 2017Digital Marketing Trends 2017
Digital Marketing Trends 2017Webrepublic
 
Social Media Trends 2017
Social Media Trends 2017Social Media Trends 2017
Social Media Trends 2017Chris Baker
 
Digital Trends in 2017: Making Business Impact in a Changing World
Digital Trends in 2017: Making Business Impact in a Changing WorldDigital Trends in 2017: Making Business Impact in a Changing World
Digital Trends in 2017: Making Business Impact in a Changing WorldEdelman
 
Finding Your Way: Understanding Magento Code
Finding Your Way: Understanding Magento CodeFinding Your Way: Understanding Magento Code
Finding Your Way: Understanding Magento CodeBen Marks
 
Magento 2 product import export
Magento 2 product import exportMagento 2 product import export
Magento 2 product import exportBenno Lippert
 
How to Install Magento on WAMP Server
How to Install Magento on WAMP ServerHow to Install Magento on WAMP Server
How to Install Magento on WAMP ServerAPPSeCONNECT
 
Shipping Table Rates for Magento 2 by Amasty | User Guide
Shipping Table Rates for Magento 2 by Amasty | User GuideShipping Table Rates for Magento 2 by Amasty | User Guide
Shipping Table Rates for Magento 2 by Amasty | User GuideAmasty
 

Andere mochten auch (12)

2017 Social Media & Content Marketing Predictions from 70 Marketing Leaders
2017 Social Media & Content Marketing Predictions from 70 Marketing Leaders 2017 Social Media & Content Marketing Predictions from 70 Marketing Leaders
2017 Social Media & Content Marketing Predictions from 70 Marketing Leaders
 
Omnichannel Customer Experience
Omnichannel Customer ExperienceOmnichannel Customer Experience
Omnichannel Customer Experience
 
E-commerce Trends from 2015 to 2016 by Divante
E-commerce Trends from 2015 to 2016 by DivanteE-commerce Trends from 2015 to 2016 by Divante
E-commerce Trends from 2015 to 2016 by Divante
 
Digital marketing Trends 2017
Digital marketing Trends 2017Digital marketing Trends 2017
Digital marketing Trends 2017
 
SEO for Ecommerce: A Comprehensive Guide
SEO for Ecommerce: A Comprehensive GuideSEO for Ecommerce: A Comprehensive Guide
SEO for Ecommerce: A Comprehensive Guide
 
Digital Marketing Trends 2017
Digital Marketing Trends 2017Digital Marketing Trends 2017
Digital Marketing Trends 2017
 
Social Media Trends 2017
Social Media Trends 2017Social Media Trends 2017
Social Media Trends 2017
 
Digital Trends in 2017: Making Business Impact in a Changing World
Digital Trends in 2017: Making Business Impact in a Changing WorldDigital Trends in 2017: Making Business Impact in a Changing World
Digital Trends in 2017: Making Business Impact in a Changing World
 
Finding Your Way: Understanding Magento Code
Finding Your Way: Understanding Magento CodeFinding Your Way: Understanding Magento Code
Finding Your Way: Understanding Magento Code
 
Magento 2 product import export
Magento 2 product import exportMagento 2 product import export
Magento 2 product import export
 
How to Install Magento on WAMP Server
How to Install Magento on WAMP ServerHow to Install Magento on WAMP Server
How to Install Magento on WAMP Server
 
Shipping Table Rates for Magento 2 by Amasty | User Guide
Shipping Table Rates for Magento 2 by Amasty | User GuideShipping Table Rates for Magento 2 by Amasty | User Guide
Shipping Table Rates for Magento 2 by Amasty | User Guide
 

Kürzlich hochgeladen

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 

Kürzlich hochgeladen (20)

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 

How I Learned to Stop Worrying and Love Magento

  • 1. What’s really under the hood? How I learned to stop worrying and love Magento
  • 2. Who am I? • Alan Storm • http://alanstorm.com • Got involved in The Internet/Web 1995 • Work in the Agency/Startup Space • 10 years php experience • The thing you can never say ...
  • 3. Not a Computer Scientist • Many developers and programmers aren’t • You don't need to be a computer scientist to work with Magento • Magento is similar to PHP Frameworks (Cake, CodeIgniter, Kohana), just deeper • Magento and Kohana, side by side • But first
  • 4. How We Got Here A Brief History of Web Development
  • 6. HTML Page • Very radical shift • No programming needed, just markup • No proprietary file format, just ASCII text • Limited interactivity, SSIs
  • 7. “Scripting” vs. “Real Programming" • HTML included markup for form elements • Stealth runtime, with client/server approach • “Real Programmers” could do everything in C, C++, Java, lisp • “Scripters” could piggy back on the web server for HTTP and produce HTML
  • 8. Perl/CGI • Perl was once the new hotness • Excelled as string processing, and Web applications are strings over HTTP • CPAN meant a shared code library • Non-complied meant distributed programs were shared in the open
  • 9. Perl/CGI • CGI was slow, and FastCGI too new • Perl didn't scale way before ruby didn't • CPAN’s good but no standard library for the growing shared hosting ecosystem
  • 10. PHP3/PHP4 • Looks like Perl! Sort of. • Build important features directly into language, distributed by default • Could import C code as extensions • The build-up/tear-down approach of mod_php ideal for shared hosts
  • 12.
  • 13.
  • 14. Rise of PHP Systems • Created to combat PHP Applications becoming too complex/messy • Shopping Cart Applications • CMS systems (Drupal, Mambo, Joomla) • Programming Frameworks, many inspired by Ruby on Rails (CakePHP, Code Igniter, Symfony)
  • 15. Magento is the Next Evolutionary Step • Is a shopping cart application • Uses a module based approach to load new code into the system, similar to Drupal • Implements a configuration based MVC • Most PHP Frameworks are convention based, Magento is configuration based
  • 16. Controllers and Routing A Web MVC Router transforms the request URL into a controller class name and decides which method on that controller is the entry point
  • 17. Kohana Routing • Routing handled by Router_Core::setup • URI: /controllerName/actionName • URI: /welcome/index • Welcome_Controller::index(); • File: /application/controllers/welcome.php
  • 18. Magento Routing • URI: /frontName/controllerName/actionName • URI: /catalogsearch/result/index • No Standard Router!
  • 19. Magento Routing • Magento Searches Global Config for routers • web/routers • Default system ships with two Routers • Mage_Core_Controller_Varien_Router_Admin • Mage_Core_Controller_Varien_Router_Standard • Configured in Mage_Core
  • 20.
  • 21. Magento Routing • The match method is called on each router • The match method is responsible for • Creating a Controller class • Creating an Action method • Calling the Action method
  • 22. Magento Routing • URI: /frontName/controllerName/actionName • URI: /catalogsearch/result/index • Default routers will • Gather any module with a configured <frontName>catalogsearch</frontName> • Check modules controllers folder for a Packagename_Modulename_ControllerName Mage_CatalogSearch_ResultController
  • 23. Magento Routing • /frontName/controllerName/actionName • /catalogsearch/result/index • If a Controller is found, Router checks if for an action. • Mage_CatalogSearch_ResultController::indexAction • If action is found, it’s called, and the module search and match search stops.
  • 24. Magento Routing • Most of the time in a fresh install • /catalogsearch/result/index • translates to • Module: Mage_CatalogSearch • Controller: ResultController • Action: indexAction
  • 25.
  • 26. Magento Routing • Possible to Add Additional Routers through event system • controller_front_init_routers • See • Mage_Cms_Controller_Router::initControllerRouters • Sets up Mage_Cms_Controller_Router with different match rules
  • 27. Front Controller Mage_Core_Controller_Varien_Router_Admin Looks at Global Config and Instantiates Routers Mage_Core_Controller_Varien_Router_Standard Goes through each Router and calls match() match() until a controller is dispatched Builds a list of Moules with matching frontName Check each module until it finds a valid controller/ action pair
  • 28. Models Getting out of the SQL Writing Business
  • 29. Kohana Models • Extend from Base ORM class • Mostly follows Active Record Pattern • Create, Read, Update, Delete • Simple Class Instantiation
  • 30.
  • 31. Magento Models • Most Complex Models implement an Entity Attribute Value store • Simpler “basic” models offers Active Record like functionality • Implement a Mapper pattern, making Model independant of data store • Client Programmer doesn’t need to know these details to use.
  • 32.
  • 33.
  • 34. Magento Models • Magento Replaces direction instantiation with a indirect static method call • $user = new User(); • $customer = Mage::getModel(‘cusotmer/customer’); • Every model has a Collection object which is used when fetching for multiple models. Kohana and other frameworks, return PHP arrays()
  • 35. Views It all comes back to HTML
  • 36. Kohana View Controller Contrller Interacts with Controller Picks specific Model based on request variables to send to view Model View
  • 37. Kohana View • Traditional PHP MVC View Pattern • Views are PHP mixed with HTML • Often called “Dumb View”, since the View doesn’t know anything about the Application
  • 38. Magento View Controller Contrller Interacts with Controller Tells Model based on request View to Kick Off Model View View Reads Data Directly from Model Objects
  • 39. Controller Contrller Interacts with Controller Tells Model based on request View to Kick Off Model View View Reads Data Directly from Model Objects
  • 40. Controller Contrller Interacts with Controller Tells Model based on request View to Kick Off Layout is a nested collection of recursively rendering blocks Model Layout Root Block Block Block Blocks Read Data Directly from Model Block Objects Block Block
  • 41. Magento Block • The simplest block is just a PHP class with a toHtml(), which returns a string • Many Blocks render via a phtml template • From within a phtml template, $this is a reference to the containing Block • The phtml templates contain HTML and PHP code for rendering logic • Block methods communicate with Models
  • 42. Block Class Template for Block Templates may be set programmatically or via the Layout XML files
  • 43. What’s really under the hood? How I learned to stop worrying and love Magento

Hinweis der Redaktion