SlideShare a Scribd company logo
1 of 33
Download to read offline
Magento 2
Replacing God with Dependency Injection
John Knowles (@knowj)
Lead Developer JH
Richard McLeod (@RMcLe0d)
Senior Developer JH
● Open source ecommerce platform
● Currently holds ~22% market share
● Started development in 2007
● Until recently owned by Ebay
● Magento 2 released November 2015
What is Magento?
Magento 1
The Good
● Extremely flexible
● Amazing community with a wide range of extensions
● Rarely have to write a payment integration
● Community driven composer compatibility
The Bad
● Learning curve (Limited documentation)
● Rewrite system
● Few interfaces
● Lots of extension
● No tests
The Ugly
● XML config errors
● Extension conflicts
● Monolithic static logger
● Core Hacks
● Mage::!!!!
At least it’s not WordPress!
Magento 1 VS Magento 2
Magento 1 - XML Config “errors”
2 hours xDebugging through the core to find this was the problem!
Magento 2 - XML Config Errors
Magento 1 - Rewrites
Magento 2 - Plugins
● Interception Pattern
● Before
● After
● Around
● No more rewrites!
Seriously EVERYWHERE!
Magento 2 - Plugins cont...
Magento 1 - The God Class
<?php
final class Mage
What is the God class?
● 1 final class
● 43 static methods
● 1000’s of developers crying
Opinions?
Or this?
The problems
● Hard to test (but possible)
● Single argument construct
● Black box nature
● Logging nightmare
● Rewrite architecture
Magento 2 - Goodbye to the God class
Magento 2 - Hello Dependency Injection
Magento 2’s DI Container
● Constructor Injection
● XML config
● Magento built DI container
Example of DI.xml
Magento 1 - Interfaces
Magento 2 - Service Contracts
● Repository Interface
● Management Interfaces
● Data Interfaces
● Search Results Interface
● Meta Data Interfaces
● Service contracts is interfaces!
Magento 2 - Service Contracts cont… Benefits
● Dependency Injection
● Guaranteed API
● Ties in with Semantic Version
Magento Listened!
Standards
● PSR-0 to 4
● Semantic Versioning
● Namespaces
● Dependency Injection
● Better Pattern Usage
● Interfaces
Features
● Feature parity with Magento 1
● CLI tool
● Varnish
● Unit and Integration and Functional Tests
● Enterprise - Multi Master/Split Databases
● Enterprise - Message Queues (RabbitMQ)
Developer friendly
● PHP7
● Still XML config but with XSDs
● Improved events
● Dependency Injection
● Plugin architecture
● Service Contracts (Interfaces)
Thanks for listening!
John Knowles (@knowj)
Lead Developer JH
Richard McLeod (@RMcLe0d)
Senior Developer JH
Any Questions?

More Related Content

Similar to Magento 2 - Replacing God with Dependency Injection

Scaling Magento
Scaling MagentoScaling Magento
Scaling MagentoCopious
 
Decoupled drupal + vue.js
Decoupled drupal + vue.jsDecoupled drupal + vue.js
Decoupled drupal + vue.jsEugene Vozniuk
 
Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Fwdays
 
Introduction to Reactjs
Introduction to ReactjsIntroduction to Reactjs
Introduction to ReactjsNodeXperts
 
RandomTest - Random Software Integration Tests That Just Work for C/C++, Java...
RandomTest - Random Software Integration Tests That Just Work for C/C++, Java...RandomTest - Random Software Integration Tests That Just Work for C/C++, Java...
RandomTest - Random Software Integration Tests That Just Work for C/C++, Java...dcieslak
 
MidwestPHP - Getting Started with Magento 2
MidwestPHP - Getting Started with Magento 2MidwestPHP - Getting Started with Magento 2
MidwestPHP - Getting Started with Magento 2Mathew Beane
 
Dmytro Dziubenko "Developer's toolchain"
Dmytro Dziubenko "Developer's toolchain"Dmytro Dziubenko "Developer's toolchain"
Dmytro Dziubenko "Developer's toolchain"Fwdays
 
Continuous integration for androids
Continuous integration for androidsContinuous integration for androids
Continuous integration for androidsKirill Zotin
 
Refactoring the monolith
Refactoring the monolithRefactoring the monolith
Refactoring the monolithSteven Hicks
 
The working architecture of NodeJS applications, Виктор Турский
The working architecture of NodeJS applications, Виктор ТурскийThe working architecture of NodeJS applications, Виктор Турский
The working architecture of NodeJS applications, Виктор ТурскийSigma Software
 
Integrating Magento into Joomla!
Integrating Magento into Joomla!Integrating Magento into Joomla!
Integrating Magento into Joomla!Yireo
 
Liferay portals in real projects
Liferay portals  in real projectsLiferay portals  in real projects
Liferay portals in real projectsIBACZ
 
Product development and tools
Product development and toolsProduct development and tools
Product development and toolsroelofr
 
Perl Continous Integration
Perl Continous IntegrationPerl Continous Integration
Perl Continous IntegrationMichael Peters
 
FRU Kathmandu: Adopting with Change Frontend Architecture and Patterns
FRU Kathmandu: Adopting with Change Frontend Architecture and PatternsFRU Kathmandu: Adopting with Change Frontend Architecture and Patterns
FRU Kathmandu: Adopting with Change Frontend Architecture and PatternsLeapfrog Technology Inc.
 
Deccan ruby-conf-talk
Deccan ruby-conf-talkDeccan ruby-conf-talk
Deccan ruby-conf-talkprchaudhari
 
Introducing Selenium Builder – the Future of Test Development
Introducing Selenium Builder – the Future of Test DevelopmentIntroducing Selenium Builder – the Future of Test Development
Introducing Selenium Builder – the Future of Test Developmentseleniumconf
 

Similar to Magento 2 - Replacing God with Dependency Injection (20)

Breaking down a monolith
Breaking down a monolithBreaking down a monolith
Breaking down a monolith
 
Advent of magento2
Advent of magento2Advent of magento2
Advent of magento2
 
Scaling Magento
Scaling MagentoScaling Magento
Scaling Magento
 
Decoupled drupal + vue.js
Decoupled drupal + vue.jsDecoupled drupal + vue.js
Decoupled drupal + vue.js
 
Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"
 
Introduction to Reactjs
Introduction to ReactjsIntroduction to Reactjs
Introduction to Reactjs
 
RandomTest - Random Software Integration Tests That Just Work for C/C++, Java...
RandomTest - Random Software Integration Tests That Just Work for C/C++, Java...RandomTest - Random Software Integration Tests That Just Work for C/C++, Java...
RandomTest - Random Software Integration Tests That Just Work for C/C++, Java...
 
MidwestPHP - Getting Started with Magento 2
MidwestPHP - Getting Started with Magento 2MidwestPHP - Getting Started with Magento 2
MidwestPHP - Getting Started with Magento 2
 
Dmytro Dziubenko "Developer's toolchain"
Dmytro Dziubenko "Developer's toolchain"Dmytro Dziubenko "Developer's toolchain"
Dmytro Dziubenko "Developer's toolchain"
 
Continuous integration for androids
Continuous integration for androidsContinuous integration for androids
Continuous integration for androids
 
Refactoring the monolith
Refactoring the monolithRefactoring the monolith
Refactoring the monolith
 
The working architecture of NodeJS applications, Виктор Турский
The working architecture of NodeJS applications, Виктор ТурскийThe working architecture of NodeJS applications, Виктор Турский
The working architecture of NodeJS applications, Виктор Турский
 
Integrating Magento into Joomla!
Integrating Magento into Joomla!Integrating Magento into Joomla!
Integrating Magento into Joomla!
 
Liferay portals in real projects
Liferay portals  in real projectsLiferay portals  in real projects
Liferay portals in real projects
 
Product development and tools
Product development and toolsProduct development and tools
Product development and tools
 
Perl Continous Integration
Perl Continous IntegrationPerl Continous Integration
Perl Continous Integration
 
How to sell drupal 8
How to sell drupal 8How to sell drupal 8
How to sell drupal 8
 
FRU Kathmandu: Adopting with Change Frontend Architecture and Patterns
FRU Kathmandu: Adopting with Change Frontend Architecture and PatternsFRU Kathmandu: Adopting with Change Frontend Architecture and Patterns
FRU Kathmandu: Adopting with Change Frontend Architecture and Patterns
 
Deccan ruby-conf-talk
Deccan ruby-conf-talkDeccan ruby-conf-talk
Deccan ruby-conf-talk
 
Introducing Selenium Builder – the Future of Test Development
Introducing Selenium Builder – the Future of Test DevelopmentIntroducing Selenium Builder – the Future of Test Development
Introducing Selenium Builder – the Future of Test Development
 

Recently uploaded

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutionsmonugehlot87
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?Watsoo Telematics
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 

Recently uploaded (20)

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutions
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 

Magento 2 - Replacing God with Dependency Injection

  • 1. Magento 2 Replacing God with Dependency Injection
  • 2. John Knowles (@knowj) Lead Developer JH Richard McLeod (@RMcLe0d) Senior Developer JH
  • 3.
  • 4. ● Open source ecommerce platform ● Currently holds ~22% market share ● Started development in 2007 ● Until recently owned by Ebay ● Magento 2 released November 2015 What is Magento?
  • 6. The Good ● Extremely flexible ● Amazing community with a wide range of extensions ● Rarely have to write a payment integration ● Community driven composer compatibility
  • 7. The Bad ● Learning curve (Limited documentation) ● Rewrite system ● Few interfaces ● Lots of extension ● No tests
  • 8. The Ugly ● XML config errors ● Extension conflicts ● Monolithic static logger ● Core Hacks ● Mage::!!!!
  • 9. At least it’s not WordPress!
  • 10. Magento 1 VS Magento 2
  • 11. Magento 1 - XML Config “errors” 2 hours xDebugging through the core to find this was the problem!
  • 12. Magento 2 - XML Config Errors
  • 13. Magento 1 - Rewrites
  • 14. Magento 2 - Plugins ● Interception Pattern ● Before ● After ● Around ● No more rewrites! Seriously EVERYWHERE!
  • 15. Magento 2 - Plugins cont...
  • 16. Magento 1 - The God Class <?php final class Mage
  • 17. What is the God class? ● 1 final class ● 43 static methods ● 1000’s of developers crying
  • 20. The problems ● Hard to test (but possible) ● Single argument construct ● Black box nature ● Logging nightmare ● Rewrite architecture
  • 21. Magento 2 - Goodbye to the God class
  • 22. Magento 2 - Hello Dependency Injection
  • 23. Magento 2’s DI Container ● Constructor Injection ● XML config ● Magento built DI container
  • 25. Magento 1 - Interfaces
  • 26. Magento 2 - Service Contracts ● Repository Interface ● Management Interfaces ● Data Interfaces ● Search Results Interface ● Meta Data Interfaces ● Service contracts is interfaces!
  • 27. Magento 2 - Service Contracts cont… Benefits ● Dependency Injection ● Guaranteed API ● Ties in with Semantic Version
  • 29. Standards ● PSR-0 to 4 ● Semantic Versioning ● Namespaces ● Dependency Injection ● Better Pattern Usage ● Interfaces
  • 30. Features ● Feature parity with Magento 1 ● CLI tool ● Varnish ● Unit and Integration and Functional Tests ● Enterprise - Multi Master/Split Databases ● Enterprise - Message Queues (RabbitMQ)
  • 31. Developer friendly ● PHP7 ● Still XML config but with XSDs ● Improved events ● Dependency Injection ● Plugin architecture ● Service Contracts (Interfaces)
  • 32. Thanks for listening! John Knowles (@knowj) Lead Developer JH Richard McLeod (@RMcLe0d) Senior Developer JH