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

ServiceNotFoundException: You have requested a non-existent service \"serializer\" #368

Closed
jesmarquez opened this issue Feb 24, 2014 · 2 comments

Comments

@jesmarquez
Copy link

Because I'm getting the following error:

ServiceNotFoundException: "You have requested a non-existent service "serializer"." at C:\wamp\www\symensay\app\bootstrap.php.cache line 1967 {"exception":"[object](Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "serializer". at C:\wamp\www\symensay\app\bootstrap.php.cache:1967)

Install the component as indicated in the documentation!

in the controller i have:
...
use JMS\SerializerBundle\Serializer\Serializer;
...

$usuarios = $query->getResult();
$serializer = $this->container->get('serializer');
$entityserializer= $serializer->serialize($usuarios, 'json');

Thank!

@theofidry
Copy link

Depending of the context, you can try $this->get('serializer')instead of $this->container->get('serializer').

If you're in a service, you have to inject the service serializer, cf. this link.

@goetas
Copy link
Collaborator

goetas commented Jan 20, 2017

Sorry for the long feedback loop. This issue is probably already solved and @theofidry solution looks good.

(if not feel free to re open the issue or to comment here)

Thanks

@goetas goetas closed this as completed Jan 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants