我正在使用 symfony 4.2 构建 Api,并希望使用 jms-serializer 在安装后以 Json 格式序列化我的数据
作曲家需要 jms/serializer-bundle
当我尝试以这种方式使用它时:
``` demands = $demandRepo->findAll();
return $this->container->get('serializer')->serialize($demands,'json');```
它给了我这个错误:
Service "serializer" not found, the container inside "App\Controller\DemandController" is a smaller service locator that only knows about the "doctrine", "http_kernel", "parameter_bag", "request_stack", "router" and "session" services. Try using dependency injection instead.