Sylius: Dependency conflicts with SyliusResourceBundle

Hi everyone,

I’m trying to create a Symfony 3.2 project from scratch (not e-commerce) with SyliusResourceBundle in order to have CRUD support out of the box for my entities. I didn’t manage to install the bundle because of composer conflicts:

$ composer require sylius/resource-bundle
Using version ^0.19.0 for sylius/resource-bundle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for sylius/resource-bundle ^0.19.0 -> satisfiable by sylius/resource-bundle[v0.19.0].
    - Conclusion: remove symfony/symfony 3.2.x-dev
    - Conclusion: don't install symfony/symfony 3.2.x-dev
    - sylius/resource-bundle v0.19.0 requires symfony/validator ^2.8 -> satisfiable by symfony/validator[2.8.x-dev, v2.8.0, v2.8.0-BETA1, v2.8.1, v2.8.10, v2.8.11, v2.8.12, v2.8.13, v2.8.14, v2.8.2, v2.8.3, v2.8.4, v2.8.5, v2.8.6, v2.8.7, v2.8.8, v2.8.9].
    - don't install symfony/validator 2.8.x-dev|don't install symfony/symfony 3.2.x-dev
    - don't install symfony/validator v2.8.0|don't install symfony/symfony 3.2.x-dev
    - don't install symfony/validator v2.8.0-BETA1|don't install symfony/symfony 3.2.x-dev
    - don't install symfony/validator v2.8.1|don't install symfony/symfony 3.2.x-dev
    - don't install symfony/validator v2.8.10|don't install symfony/symfony 3.2.x-dev
    - don't install symfony/validator v2.8.11|don't install symfony/symfony 3.2.x-dev
    - don't install symfony/validator v2.8.12|don't install symfony/symfony 3.2.x-dev
    - don't install symfony/validator v2.8.13|don't install symfony/symfony 3.2.x-dev
    - don't install symfony/validator v2.8.14|don't install symfony/symfony 3.2.x-dev
    - don't install symfony/validator v2.8.2|don't install symfony/symfony 3.2.x-dev
    - don't install symfony/validator v2.8.3|don't install symfony/symfony 3.2.x-dev
    - don't install symfony/validator v2.8.4|don't install symfony/symfony 3.2.x-dev
    - don't install symfony/validator v2.8.5|don't install symfony/symfony 3.2.x-dev
    - don't install symfony/validator v2.8.6|don't install symfony/symfony 3.2.x-dev
    - don't install symfony/validator v2.8.7|don't install symfony/symfony 3.2.x-dev
    - don't install symfony/validator v2.8.8|don't install symfony/symfony 3.2.x-dev
    - don't install symfony/validator v2.8.9|don't install symfony/symfony 3.2.x-dev
    - Installation request for symfony/symfony (locked at 3.2.x-dev, required as 3.2.*) -> satisfiable by symfony/symfony[3.2.x-dev].


Installation failed, reverting ./composer.json to its original content.

Then I updated my composer.json to set minimum-stability to dev and tried this:

$ composer require sylius/resource-bundle dev-master
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for sylius/resource-bundle dev-master -> satisfiable by sylius/resource-bundle[dev-master].
    - Conclusion: remove sensio/framework-extra-bundle v3.0.16
    - Conclusion: don't install sensio/framework-extra-bundle v3.0.16
    - sylius/resource-bundle dev-master requires friendsofsymfony/rest-bundle ^1.8 -> satisfiable by friendsofsymfony/rest-bundle[1.8.0, 1.8.0-BETA1, 1.8.0-BETA2, 1.8.x-dev].
    - friendsofsymfony/rest-bundle 1.8.0 conflicts with sensio/framework-extra-bundle[v3.0.16].
    - friendsofsymfony/rest-bundle 1.8.0-BETA1 conflicts with sensio/framework-extra-bundle[v3.0.16].
    - friendsofsymfony/rest-bundle 1.8.0-BETA2 conflicts with sensio/framework-extra-bundle[v3.0.16].
    - friendsofsymfony/rest-bundle 1.8.x-dev conflicts with sensio/framework-extra-bundle[v3.0.16].
    - Installation request for sensio/framework-extra-bundle (locked at v3.0.16, required as ^3.0.2) -> satisfiable by sensio/framework-extra-bundle[v3.0.16].


Installation failed, reverting ./composer.json to its original content.

I even tried to downgrade to Symfony 3.1 then Symfony 3.0 (fresh installs each time), but I still have composer issues. What is your advice?

Thank you in advance, Ben

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (15 by maintainers)

Most upvoted comments

Hi there again,

Now that I succeeded in installing SyliusResourceBundle with Symfony 3.2, I’m following the tutorial in the documentation, but it still doesn’t work out of the box: http://docs.sylius.org/en/latest/bundles/SyliusResourceBundle/configuration.html

Translator issue

I have registered the /books endpoint as an api resource:

# app/config/config.yml 
sylius_resource:
    resources:
        app.book:
            classes:
                model: AppBundle\Entity\Book

# app/config/router.yml
app_book:
    resource: |
        alias: app.book
    type: sylius.resource_api

Now when I call GET http://localhost:8000/books, an exception is raised:

Type error: Argument 2 passed to Sylius\Bundle\ResourceBundle\Controller\FlashHelper::__construct() must be an instance of Symfony\Component\Translation\TranslatorBagInterface, instance of Symfony\Component\Translation\IdentityTranslator given

Indeed, with a fresh Symfony install, the following line in config.yml is commented by default:

# app/config/config.yml
framework:
    #translator:      { fallbacks: ["%locale%"] }

As a result, the translator service maps to Symfony\Component\Translation\IdentityTranslator class, which does not translate anything, and is not instanceof Symfony\Component\Translation\TranslatorBagInterface .

Uncommenting that line maps the translator service to Symfony\Component\Translation\DataCollectorTranslator which solves the problem.

I don’t know if this is a bug, or if enabling the translation component is mandatory for the bundle to work. In that case, you should mention this in the doc.

Content-negociation issue

Then, when calling GET http://localhost:8000/books with an Accept: application/json header, the following exception is raised:

Unable to find template “/index.html.twig”

Since I requested a JSON response, why looking for a template? In fact, FOSRestBundle needs to be configured, I didn’t figure that out at the first glance. Maybe mentionning this in the doc would help newbies like me 😃

First resource creation issue

Now that I have a JSON response on the index, I’d like to create my first book, as told in the tutorial.

curl -i -X POST -H “Content-Type: application/json” -d ‘{“title”: “Lord of The Rings”, “author”: “J. R. R. Tolkien”, “description”: “Amazing!”}’ http://localhost:8000/books/

Here’s the result:

Class “form” is not configured for resource “app.book”.

Do I need to create a form for my Book example? I thought form generation was automatic since the bundle has an option to use a “custom” form.

Sorry for bothering you, I’m not even certain this is the right place to ask for help, but I noticed you put big efforts in the documentation to make things easy and the DX perfect, so I’d like to contribute to that 😉

Thanks, Ben

@lchrusciel is on it right now! 😃

@venyii, that works! Excellent. I’m going through and trying to update the documentation as I find deficiencies and ambiguities, so this should help a bunch. I hope this also helped @bpolaszek with his issue?

Oh, you. ❤️

@baublet Yes, that is the case since the recent Symfony 3 upgrade. form should be a class now, like in https://github.com/Sylius/Sylius/pull/6878/files#diff-476eba1ccbee1d4df669cd3452bdd165R20

Try using ^1.0@beta in your composer.json. Or composer require -s beta sylius/resource-bundle.

@TheMadeleine We should use stability beta in all bundle documentations. Can you do a quick fix please?