Question

I need to integrate Sylius within an existing Symfony 2.4 project. This project already has a list of dependencies, to which I've added the Sylius dependencies. Everything works fine but one dependency: the knplabs/knp-menu-bundle used by the project is 2.0.*@dev and the bundle required by sylius/web-bundle is of version 1.1.*.

Now when trying to run a composer install --prefer-dist it obviously gives a conflict:

Your requirements could not be resolved to an installable set of packages.

Problem 1
- sylius/web-bundle 1.0.x-dev requires knplabs/knp-menu-bundle 1.1.* -> satisfiable by knplabs/knp-menu-bundle[1.1.x-dev].
- sylius/web-bundle 1.0.x-dev requires knplabs/knp-menu-bundle 1.1.* -> satisfiable by knplabs/knp-menu-bundle[1.1.x-dev].
- Conclusion: don't install knplabs/knp-menu-bundle 1.1.x-dev
- Installation request for sylius/web-bundle 1.0.*@dev -> satisfiable by sylius/web-bundle[1.0.x-dev].

Removing the below explicit mention will make composer work and checkout version 1.1 (as required by web-bundle):

    "knplabs/knp-menu":                         "2.0.*@dev",
    "knplabs/knp-menu-bundle":                  "2.0.*@dev",

But, of course, gives me errors in the application because the original application requires logic from version 2.

Here is my entire composer.json: http://pastebin.com/V36jy93p

How would I best go about fixing this? Can I somehow make the Sylius web bundle utilize the knp-menu-bundle version 2?

Was it helpful?

Solution

Probably the main error is to use a package that is only of development stability. From what I see on packagist.org, the "knplabs/knp-menu-bundle" has had an alpha release more than 9 months ago, and the development branches last commit only a week ago. I don't know if this can tell me something, but I think the developers might see their software not be ready to production use, and probably would recommend using the older 1.x version instead.

And IF they think this is true, the same software from these guys, "sylius/web-bundle", only relies on that older version, and this complete fits into that picture. That software's dependency hasn't been released in the new version, so there is no need to also release that software with a new package.

Note that previous versions of "sylius/web-bundle" do actually depend on the 2.0.*-dev version of "knplabs/knp-menu-bundle", but I wonder why they stepped down from that version in later releases. It probably triggered too many problems tracing an ongoing development that lead to no released software for 9 months.

And as a general remark, I'd say that your composer.json has way too many "dev-master" and "@dev" versions included to resolve to a stable bunch of dependencies.

But what can you do? Aliasing the "knplabs/knp-menu-bundle" as version 1.1.x might help. You might quickly find out which software dependencies this will destroy because of incompatible classes - in the worst case, this will only ever be found out after you pushed your code to production (you do have tests to find out, don't you).

You could also raise an issue with the developers of "sylius/web-bundle" to release a version that depends on the 2.0.x-dev version of "knplabs/knp-menu-bundle".

Another method would be to clone the "sylius/web-bundle" project, change that line in their composer.json that depends on "knplabs/knp-menu-bundle", fix any possible issued due to that change, create a pull request for the original project with this change, and until that happens, you can include your own repository instead of the original one by adding the Github URL into the repositories section of your composer.json.

You could also try to persuade the guys of "knplabs/knp-menu-bundle" to tag another release so that more packages are able to depend on that new tag instead of not depending on the development branch (doing so will break things unexpectedly, which is a no-go if you release stable software). And after that once again trigger "sylius/web-bundle" to try and use that new version.

If everything else fails, the last option: Don't use "sylius/web-bundle". Or don't use "knplabs/knp-menu-bundle" version 2.0.x-dev.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top