Magento 2 : How to get version of Magento 2?

Determine Magento 2

Quick article on Magento 2 for our Magento 2 community developers. Today we are going to find out how to determine Magento 2 version in four different ways. It includes through code, CLI command, admin interface and composer.json file. Let’s go through all the four options in details.

Option 1 – Through your Magento 2 code

 /** * @var MagentoFrameworkAppProductMetadata */ protected $productMetadata; /** * @param MagentoFrameworkAppProductMetadata $productMetadata */ public function __construct( MagentoFrameworkAppProductMetadata $productMetadata ) { $this->productMetadata = $productMetadata; } /** * Return Magento version * * @return string */ protected function getMagento2Version() { return $this->productMetadata->getVersion(); }

Option 2 – Go to root of your Magento folder by SSHing on your webserver & run the following command

php bin/magento --version

Option 3 – Go to root of your Magento folder and open composer.json file as shown below -:

Option 4 – Login to your Magento admin and check right bottom part of the screen as shown below -:

Magento 2 version through admin interface

That’s it, Hope this article helped you in some way. Please leave us your comment and let us know what do you think? Thanks.

Discover more from WHO WILL CARE eCommerce

Subscribe now to keep reading and get access to the full archive.

Continue reading