News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Kevin Schroeder:
(Basic) Configuring the Magento 2 Dependency Injection Container
December 16, 2013 @ 12:03:22

Kevin Schroeder continues his series of posts looking at using Magento 2 and creating customizations of the application. In this latest post he builds on the previous post about dependency injection and shows how to configure Magento's container.

The purpose of that post was to, perhaps, make you less apprehensive about using DI combined with the DIC in Magento 2. However, in this post I want to go a little deeper into the DIC, implemented via the MagentoObjectManagerObjectManager class, and talk about how to configure it. Configuration for the DIC is done in each module's etc/di.xml file or etc//di.xml. Because you can split DIC configuration based on the area this tells you that the /config/ naming stuff is over; which I applaud.

He focuses more specifically on two of the child nodes that can be defined - "type" and "preference" (you can also have "virtualType" as well). First up is "type" and he gives a simple example class in his "HelloWorld" example that just takes in a message and returns it when asked. He shows it in use and how to set up the "di.xml" configuration for the class, defining the "message" parameter in the configuration instead of in the object fetch (like the first example).

0 comments voice your opinion now!
magento2 dependency injection container configuration usage tutorial

Link: http://www.eschrade.com/page/basic-configuring-the-magento-2-dependency-injection-container/

Kevin Schroeder:
(Starting) Using Dependency Injection in Magento 2
December 13, 2013 @ 11:50:45

Kevin Schroeder is continuing his current trend of posts with another new one about Magento 2 and using deendency injection and how to use it inside your Magento extension code.

I wrote an introduction to Dependency Injection for Zend Framework a while back and was able to work out some of the kinks in my understanding of how a DI container worked with 4 blog posts. It took a while for me to get it but much of what I learned for Zend Framework does directly apply for Magento 2. Dependency Injection is handled in Magento 2 via the class MagentoAppObjectManager. And if you look at that from within the context of Magento 2 you are probably pooping your pants. 200+ class instances, configuration options, dogs and cats living together.

He starts with a simple script that calls the DI container to get an instance of a "Test" class. He talks about the difference between this and calling "new" and gives a bit more complex example with a custom "Test2" class. It's only slightly more complex as he shows how an instance of "Test2" with a property of a "Test" instance gets created and built out and injected into the "Test2" class on initialization.

0 comments voice your opinion now!
dependency injection magento2 tutorial introduction

Link: http://www.eschrade.com/page/using-dependency-injection-in-magento-2/

Kevin Schroeder:
Creating a module in Magento 2
December 12, 2013 @ 09:15:40

Kevin Schroeder has posted a step-by-step guide to his site today about creating a module for Magento in the first of a series of posts about Magento.

I believe that one of the best ways to learn something is to write out what it is you are learning. This forces you to think through the concepts and determine how to explain them to others. In doing so you are forced to use terms that are familiar to describe this new thing. This helps to solidify the concepts in your own mind, making it easier to remember. But still, there are three caveats: Magento 2 is not out yet, I'm learning as I write and what I share is what I see (my interpretation).

He talks about some of the differences between Magento 1 and 2 including:

  • The lack of code pools
  • Discovery XML files are in a different location
  • A different parser for these XML files

With all of this configuration and location information covered, he gets into the actual module building. He makes a simple "Hello World" module with a module.xml, event.xml and an Observer that handles sending the text back to the waiting application.

0 comments voice your opinion now!
tutorial module magento2 module event observer

Link: http://www.eschrade.com/page/creating-a-module-in-magento-2/


Community Events





Don't see your event here?
Let us know!


list framework language tips bugfix podcast library opinion community release install series api deployment introduction interview voicesoftheelephpant package symfony laravel

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework