Joomla!Day Poland 2013 - Joomla Architecture (Ofer Cohen)

  • Published on

  • View

  • Download


Joomla architecture - what happened behind the scenes. Did you always wanted to know what happened behind the scenes of Joomla code? Come and find what triggered down to up with real life scenarios, like MVC architecture, Plugin design pattern, how getDBO bring me the database instance and much more.


1.Joomla Architecture Revealed! Ofer Cohen @oc666 2. About me, Joomla and Arch Open source volunteer since 2005. Joomla volunteer since 2007. CMS & Framework code contributor JBS team member GSoC mentor of Joomla Extensions Developer (TP2 at JomLand) 3. nie wystarczy? Joomla Hebrew translation coordinator Joomla Israeli community leader Joomla!Day Israel organiser OSM board member Daily job: R&D manager in the Start-Up nation. 4. Joomla! 3.2% of all websites, worldwide Object Oriented since 1.5 Components based on MVC design pattern What else? 5. Architecture? Architecture the process and product of planning, designing and construction... Software architecture description of the system that support in the understanding of how the system will behave Website architecture approach to the design and planning of websites... 6. Revealed? Who cares? It Just Works! (TM) 7. Revealed! Why is my Joomla! site slow? hacked?.. Want to build a complicated website? What are the abilities of Joomla? What can't I do with Joomla? I just love to research and learn! 8. Object Oriented Data structures consisting of data fields and methods together with their interactions Programming techniques include features such as data abstraction, encapsulation, messaging, modularity, polymorphism, and inheritance. This approach make your program more easy to build and implement tricks. 9. Tricks? The tricks are design patterns - reusable solutions to commonly occurring problems within a given context in software design. (wikipedia) 10. Step back.... J! index.php 1. constants and defines declared 2. configuration loaded 3. application init triggered (lang, editor) 4. routing parsed the request (url, arguments) 5. dispatch the component 6. render the template 7. echo the response output 11. Looks simple, but what's inside? 1. Component is first dispatched and then buffered. 2. Template render with their modules and then set output into response (object). 3. Events trigger between each step. 12. Template Walk... --> How is a template rendered? 1. The index.php of the template is rendered. 2. Parsing jdoc statements. 3. Each jdoc statement rendered separately, iteratively, according to its type. 4. Component & head are parts of the iteration, but have different rendering. 13. VMC... MCV... WTF? Prefer BMW? MVC - Model-View-Controller Divide the software into 3 layers: M=>Logic V=>User interface C=>Request handler 14. MVC - advantages Easier to extend. Less spaghetti code. Great approach on upgrades and new features. Easier collaboration between multiple developers. 15. Events handling Simple dispatcher can be called It fires events to Joomla plugins on basic triggers. For example, after content creation, before user delete, etc. Plugin=Observer 16. Supplier of the main entities of Joomla: Session User Cache Database and more... Each entity is singleton Factory 17. Only one instance of an object is kept. Saves system memory usage & cpu Singleton 18. Adapter Adapter translates one interface for a class into a compatible interface. For example DB adapter for DB such as MySQL, MSSQL, Postgresql. Another example would be Renderer object for rendering output of module, component, header, etc. 19. Decouple an abstraction from its implementation. Useful for implementation encapsulation. Especially when the program decides how to implement on run time. Bridge 20. J!Database instance built by its instantiator method input. The method will return its nested inheritance object The object type would be unknown, only the methods we can call would be known. Bridge - example 21. abstract class JDatabase { public static function getInstance($options) { $class = 'JDatabase' . ucfirst($options['driver']); $instance = new $class($options); self::$instances[$signature] = $instance; return self::$instances[$signature]; } } Bridge - code example from J!DB 22. HMVC - reuse of each part of the MVC pattern. Traits - the long tail story UCM - want to select from articles content and virtuemart products at the same query. ORM-Like methods (NOSQL). Future 23. The only complicated thing is the problem. The solution must be simple. If you have a complicated solution, you probably chose the wrong solution (KISS) Conclusion 24. Ofer Cohen Open Source Matters @oc666 Thank you 25. Coupon: jdpl13 Discount: 50% TP2 - drag & drop your modules