I'm creating a module in order to fix a bug in Magento 2.3.0 that will be part of the next release. So, I would like to restrict via Composer the dependencies of that module.

How can I restrict my module to run just with the Magento 2.3.0?


You can check the Magento 2 version and run it when it's the version that you want, if not you can add a log warning to show a message like this example:

if($this->helper->getVersion() !== self::MAGENTO_COMPATIBLE_VERSION){
    $this->logger->emergency('You are using a updated Magento version ' . Data::AMASTY_MODULE_NAME .'. Please check the module MyCompany_HotFix compatibility!' );


How to check the Magento 2 version?

How to use logger?

  • Hello Rafael, Is there any functionality like that if Magento 2.3.x run then php version 7.2 will set or if Magento 2.2.x run then php version 7.0 will set. – Rohan Hapani Dec 8 '18 at 4:24

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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