i am working in command class, when i inject a class in constructor and run di complie, it gives error of "area code is not set", when i remove injected class form the constructor then my command is working, taking argume
1 Answer
Inject \Magento\Framework\App\State
in your __construct
and following code into your execute function
try {
$this->state->getAreaCode();
} catch (\Exception $exception) {
$this->state->setAreaCode(\Magento\Framework\App\Area::AREA_ADMINHTML);
}