Symfony (3.4.2) - Error: Controller "fos_rest.exception.twig_controller" cannot be fetched from the container because it is private
Asked Answered
S

1

5

I'm on an api project using FOSRestBundle on Symfony 3.4 and have some error when I want to use my own error messages. It says me:

Controller "fos_rest.exception.twig_controller" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"

I'm stuck on this error, I think a config is missing but I don't understand which one...

Thanks

Suburb answered 9/1, 2018 at 15:44 Comment(8)
Consider updating your question with the FOS lines from your composer.json file. If any of them have '@dev' in them then remove the '@dev' and run composer update and see what happens.Melancholy
Hi, thanks for your answer. I don't have the @dev in my composer.json require: "friendsofsymfony/rest-bundle": "^2.3"Suburb
Okay. Go into app/config/services.yml and set public:true under _defaults. This is just another guess and it may cause more trouble than it is worth. And while you at it, verify you have templating: engines: ['twig'] in your framework config.Melancholy
@Cerad, my _defaults public is already on true. It seems to be a config to put on the exception controller but I don't realy know how because of my noobie's skills^^Suburb
Post a link to the docs you are following to config your own error message.Melancholy
It is a french course on OpenClassRooms: openclassrooms.com/courses/…Suburb
Oh. French. That explains it. Just kidding. All I can suggest is that you read through the official docs and see if there is anything useful. S3.3/3.4 do have quite a few changes that might not be covered in the tutorial. symfony.com/doc/3.4/controller/error_pages.htmlMelancholy
@Melancholy Ahah new on Symfony AND french :/... But isn't Symfony french? :p Ok thanks, I'll read it again to see if I didn't miss something somewhere...Suburb
S
17

I found the solution: Add to your config.yml, in fos_rest:

fos_rest:
    //
    exception:
        //
        exception_controller: 'fos_rest.exception.controller:showAction'
Suburb answered 9/1, 2018 at 17:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.