Why Magento 2.s Prohibited The Direct Use of The ObjectManager

Magento 2 prohibits the direct use of the ObjectManager in code because it hides the real dependencies of a class

Magento 2.x Coding Standard Rules / Regulations

The main reason, the Object Manager directly is that direct use of the Object Manager causes the extension not to be installable in compiled production mode.

Never call the object manager directly because the Magento 2 Framework handles this automatically

By 2017, The Magento 2 Marketplace runs a compile and install test on all extensions by using properly Magento 2 Coding Standard. If your extension uses the Object Manager directly, it will fail these tests and be rejected from the Marketplace until you resolve this problem and reupload.

How To Setup Magento 2.x Coding Standard

Leave a Reply

Your email address will not be published. Required fields are marked *