How does Symfony handle POST method towards controllers? For example, this code in ASP.NET makes it possible to use an exact similar name for a controller, in a different manner:
public ActionResult Create()
{
return View();
}
// POST: Objects/Create
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create()
{
//Code here that only runs on POST method of a form
return View();
}
I have seen something like:
public function createAction()
{
return $this->render('formPage.html.twig');
}
/**
* @Method({"POST"})
*/
public function createAction()
{
//Some code...
return new Response('Added item with id: ' . $item->getId() . 'to database');
}
Is the latter possible and similar to the former? Is it necessary to use such annotation like this or can it also be added to routing and if so, should I make different routing names or something?
movie_create:
path: /movies/create
defaults: { _controller: AppBundle:Movie:create }