How to check mode in Magento 2?

Member

by daisha , in category: PHP CMS , 8 months ago

How to check mode in Magento 2?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by tressie.damore , 3 months ago

@daisha 

In Magento 2, you can check the current mode by using the following methods:

  1. Using the command line:


You can use the following command to check the current mode:

1
bin/magento deploy:mode:show


This command will output the current mode, either "default" or "production".

  1. Using the Admin panel:


You can also check the current mode from the Magento Admin panel by following these steps:

  • Log in to the Magento Admin panel.
  • Go to System > Tools > Web Setup Wizard.
  • Click the "System Configuration" button.
  • In the "Current Configuration Mode" section, you will see the current mode. It will be either "default" or "production".
  1. Using code:


You can also check the current mode by using the following code:

1
2
3
4
5
<?php

$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$mode = $objectManager->get(MagentoFrameworkAppState::class)->getMode();
echo $mode;


This code will output the current mode as a string, either "default" or "production".