How to check programmatically if you are in the admin panel in Magento 2

- Magento 2

Magento 2 Development

Unfortunately, Magento 2 offers a more complicated solution for checking whether you are in the admin panel.


In case of Magento 1.x, you should use the following line of code:

For Magento 2 the same operation does not look so simple:


 More tips from the Cookbook