I am using Symfony and developing an independent reusable bundle, I want to install this package in symfony app.
Here is my composer.json look like in reusable bundle
{
...
"require": {
"php": ">=8.1",
"symfony/orm-pack": "2.2.0",
"knplabs/doctrine-behaviors": "2.0.8"
}
}
Here is my composer.json for Symfony app
{
"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=8.1",
"ext-ctype": "*",
"ext-iconv": "*",
"symfony/console": "6.1.*",
"symfony/dotenv": "6.1.*",
"symfony/flex": "^2",
"symfony/framework-bundle": "6.1.*",
"symfony/runtime": "6.1.*",
"symfony/yaml": "6.1.*"
},
"require-dev": {
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true,
"symfony/flex": true,
"symfony/runtime": true
},
"optimize-autoloader": true,
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*",
"symfony/polyfill-php73": "*",
"symfony/polyfill-php74": "*",
"symfony/polyfill-php80": "*",
"symfony/polyfill-php81": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "6.1.*"
}
}
}
When I try to install my reusable bundle, it always gives me this error
Problem 1
- knplabs/doctrine-behaviors v2.0.8 requires symfony/cache ^4.4|^5.1 -> found symfony/cache[v4.4.0, ..., v4.4.48, v5.1.0, ..., v5.4.15] but the package is fixed to v6.1.7 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
- oromedialab/corebundle 0.0.1 requires knplabs/doctrine-behaviors 2.0.8 -> satisfiable by knplabs/doctrine-behaviors[v2.0.8].
- Root composer.json requires oromedialab/corebundle ^0.0.1 -> satisfiable by oromedialab/corebundle[0.0.1].
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require oromedialab/corebundle:*" to figure out if any version is installable, or "composer require oromedialab/corebundle:^2.1" if you know which you need.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
Why is the conflict happening here?
Thanks
CodePudding user response:
You shouldn't set specific dependencies versions in reusable package because it can cause some conflicts. Add ^
to version declarations.
{
...
"require": {
"php": ">=8.1",
"symfony/orm-pack": "^2.2.0",
"knplabs/doctrine-behaviors": "^2.0.8"
}
}