Use Composer constraint for customized modules
Edit on GitHubSpryker OS is modular and follows the rules of semantic versioning. Every backward compatibility (BC) breaking change of module API is considered a major release. However, what happens to non-API? Spryker can change non-API functionalities in minor and patch releases. This way Spryker provides new features for different business verticals.
When you customize Spryker modules by changing their behavior on the project level, even minor changes could potentially cause migration efforts. To avoid such cases and keep project updates safe and predictable, a project should use ~ (tilde) composer constraint instead of ^ (caret) for the customized modules.
To easily detect the extended core modules and to update composer.json
constraints from using ^
to ~
, Spryker provides the Composer Constrainer tool vendor/bin/console code:constraint:modules
. The tool suggests required changes in composer.json
.Similarly, you can check non-Spryker package usage as well. If some classes of non-Spryker vendors were used on a project level, you may also validate corresponding packages to be locked to a minor version.
Install the Composer constrainer
- Require the
ComposerConstainer
module:
composer require --dev spryker-sdk/composer-constrainer
This is a development-only “require-dev” module. Make sure you include it as such.
-
Add the console command
SprykerSdk\Zed\ComposerConstrainer\Communication\Console\ComposerConstraintConsole
to yourPyz\Zed\Console\ConsoleDependencyProvider::getConsoleCommands()
insideif ($this->getConfig()->isDevelopmentConsoleCommandsEnabled()) {
to enable it only in the development mode. -
Generate transfers:
console transfer:generate
Use the Composer constrainer
- Run the command:
vendor/bin/console code:constraint:modules -d
This command makes no changes in the composer.json. The return code of this command is either 0 (success) or 1 (error, some constraints need to be changed). This is the recommended hook for your CI system. The full version of the -d
option is also available as --dry-run
.
- Run the command:
vendor/bin/console code:constraint:modules -dw
This command validates not only Spryker packages but any other vendor packages as well. The full version of the -w
option is also available as --with-foreign
.
- Run the command:
vendor/bin/console code:constraint:modules
This command changes the project’s composer.json
. Make sure you dry run the command before applying the changes with this command.
- Run the command:
vendor/bin/console code:constraint:modules -w
This command changes the project’s composer.json
with consideration of any usage of vendor packages.
Thank you!
For submitting the form