I know what object manager is. I know why it is used. I know that as a general rule it shouldn't be used. I know why from reading this. https://devdocs.magento.com/guides/v2.3/extension-dev-guide/object-manager.html#exceptions.

Then I see code like this


public function __construct(
    $this->scopeConfig = $scopeConfig ?: ObjectManager::getInstance()->get(

Which seams like an elegant way of doing it. Especially in something so abstract. So my questions are this:

  • a) Is the above still considered bad practice?

  • b) In this purely to maintain backward compatibility? Or is there another reason?

1 Answer 1


a) Yes, it is bad practice

b) Yes, it is purely to maintain backward compatibility


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.