Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime exception "__construct()" references interface "Enqueue\Client\ProducerInterface" but no such service exists #376

Closed
AlexBBBril opened this issue Feb 21, 2018 · 3 comments · Fixed by #382

Comments

@AlexBBBril
Copy link

AlexBBBril commented Feb 21, 2018

I using enqueue/enqueue-bundle in symfony 4

I'm trying to get a producer in the controller, for further work with him. By passing Producer class to the constructor, i get a type error, since in the test environment, the traceable_producer: true is set in the config, and in the standard traceable_producer: false.
If i pass ProducerInterface, i get a RuntimeException.

Full exception text "Cannot autowire service "App\Controller\TestController": argument "$producer" of method "__construct()" references interface "Enqueue\Client\ProducerInterface" but no such service exists. It cannot be auto-registered because it is from a different root namespace. Did you create a class that implements this interface?"

This behavior is fixed by adding to the services.yml the line
Enqueue \ Client \ ProducerInterface: '@ enqueue.producer
but it seems to me that this is not the best way to work out of the box.

Thanks!

@makasim
Copy link
Member

makasim commented Feb 21, 2018

There must be an alias with the producer interface as id to this service

@AlexBBBril
Copy link
Author

@makasim, tnanks for your answer. But what if I need TraceableProducer in a test environment?

@makasim
Copy link
Member

makasim commented Feb 22, 2018

As for TraceableProducer there must be a separate alias, which is present only in testing env.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants