So, I have to develop two different extension for M2.0.x or M2.1.x for
achieving compatibility?
Is their any code difference between M2.0.X and M2.1.X?
Short answer: Yes and yes a lot.
Long answer (quoting Vinai who gave me a great explanation about it recently):
Disclaimer: this reflects an understanding of things (which might be incomplete)
When developping a module for Magento 2, you need to add composer dependencies on the module your module depends on. In your case, one of this dependency is the magento/module-checkout
.
The dependency should be an exact version if you use methods/constants/classes without @api
and on the major version if you only use methods with @api
.
If a module uses anything non @api
(a class name, a method, a constant in a non @api
class...) the module should depend on the exact version of the dependency.
For example for Magento 2.1.2:
"require": {"magento/module-checkout":"100.1.2"}
If a module only uses something marked with @api
from a module, it is enough to depend on the major version only.
For example:
"require": {"magento/module-checkout":"^100.1.2"}
If a module uses observers or JS UI components, then a dependency on the minor version should be added:
For example:
"require": {"magento/module-checkout":"100.1.*"}
So as an extension developer, here are the steps to take after a Magento upgrade:
- upgrade Magento (this might require allowing the new version in the module's composer json)
- run the tests you wrote for your module
- if they pass, publish a new version of the module with the updated dependency. Now customers using the module are able to upgrade Magento
- if they don't pass, fix the issue and goto 2
Ideally, IF (big if) everybody adds the proper dependencies, an installation cannot be upgraded before all modules are compatible with the new version.
This process won't be as simple as it sounds. In theory, extension vendors would use the develop
branch / beta / RC versions to run their module tests before a release and make that phase shorter.