R
R
rolege2016-05-02 22:23:38
symfony
rolege, 2016-05-02 22:23:38

What is the magic in symfony?

Hello. Just started studying symphonies. There is little information on the framework. Therefore lamersky question.
What is the magic in the demo app? Is it so automatic and framed the slug, and found a post on it?

public function postShowAction(Post $post)
{   
    return $this->render('blog/post_show.html.twig', array('post' => $post));
}

Somehow the meaning of the controller is lost, as an intermediary between the model and the view.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Skobkin, 2016-05-02
@rolege

@ParamConverter .
If you just select a record by id and send it to the view - yes, it's lost.

S
Sergey, 2016-05-02
Protko @Fesor

Somehow, the meaning of the controller is lost, as an intermediary between the model and the view.

1) Symfony is not an MVC framework, it's a request/response framework. More correct terminology for the HTTP framework.
2) Controllers are not one class, in this case it is the entire layer from the entry point, the front of the controller, to the controller action itself. View in this case is HTTP, passive view and nothing more. By itself, she can do nothing, this is a stupid representation of the data collected by the controller.
This approach has a name - Model-View-Adapter or Mediating-controller MVC, but all these are just useless details.
3) ParamConverters are great at reducing code duplication in controllers, but working with entities in controllers is a rather dangerous business. This is a kind of compromise between "correct architecture" and "development cost.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question