craue / CraueFormFlowBundle

Multi-step forms for your Symfony project.
MIT License
736 stars 118 forks source link

Symfony 3.4/4.0 - Attribute "autowire" on service cannot be inherited from "_defaults" when a "parent" is set. #308

Closed kironet closed 6 years ago

kironet commented 6 years ago

The "App\Form\Checkout\CheckoutFlow" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.

or

Attribute "autowire" on service "App\Form\Checkout\CheckoutFlow" cannot be inherited from "_defaults" when a "parent" is set. Move your child definitions to a separate file or define this attribute explicitly in /Users/name/Documents/Projects/Symfony/project-name/config/services.yaml (which is loaded in resource "/Users/name/Documents/Projects/Symfony/project-name/config/services.yaml").

services:
    # default configuration for services in *this* file
    _defaults:
        # automatically injects dependencies in your services
        autowire: true
        # automatically registers your services as commands, event subscribers, etc.
        autoconfigure: true
        # this means you cannot fetch services directly from the container via $container->get()
        # if you need to do this, you can override this setting on individual services
        public: false

     App\Form\Checkout\CheckoutFlow:
         public: true
         parent: craue.form.flow
kironet commented 6 years ago

Looks like this bundle is dead?

craue commented 6 years ago

What are you trying to tell me? Is there an issue with the bundle? Please make clear what's wrong.

kironet commented 6 years ago

@craue

I'm using Symfony 3.4(Flex). Installed bundle, added service and getting this error:

Attribute "autowire" on service "App\Form\Checkout\CheckoutFlow" cannot be inherited from "_defaults" when a "parent" is set. Move your child definitions to a separate file or define this attribute explicitly in /Users/name/Documents/Projects/Symfony/project-name/config/services.yaml (which is loaded in resource "/Users/name/Documents/Projects/Symfony/project-name/config/services.yaml").

With Symfony 3.3 bundle worked just fine.

I temporarily fixed it by moving(copying) everything from _default to each service(except forflow bundle) individually, but don't think this is the best solution.

craue commented 6 years ago

Seems you cannot set defaults for autowire and/or autoconfigure when using parent for the service. I guess just avoiding defaults is the easy way to solve this issue. Looks like a Symfony limitation, so I'm not sure what I could do about it.

pculka commented 6 years ago

https://github.com/symfony/symfony/issues/25621 this ain't a bug