ADR Responder question

I am following Odans’ tutorial and I am to the responder part and I have a question about this sentence. “According to ADR there should be a responder for each action. In most cases a generic responder (see Responder.php) is good enough.” Looking at the code the redirect function does the same thing as
return $this->twig->render($response, ‘hello.twig’, $viewData);
Am I wrong about this? And if I am correct why do I need a responder?

Hi @meazy If you look at the Responder class you see that there are other methods for generating different types of responses. In practice, I find it much simpler to include the same responder and just invoke the desired method. In this specific case: Yes, you could also just use Twig directly, but this not count for the other methods.

Would you have an example of a responder with twig? I understand the concept but I’m confused about how the response would work with twig.

I think I understand what the responder does. I guess my question is why? Why would you build a class to do what twig already does, and then put the twig function inside a class to call a method in an action class?

I’m not sure what you mean. The Responder class is a generic responder that can be used for multiple action handler.

I guess my question is why?

It’s just a practical reason. If you want to replace the template engine, you only have to change it in one place.

Why would you build a class to do what twig already does, and then put the twig function inside a class to call a method in an action class?

The Slim4-Skeleton uses slim/php-view instead of Twig.
Twig is just another Template engine. You can replace this part of the code with Twig if you want.