This is my controller:
/**
* Finds and displays a Formacion entity.
*
* @Route("/{id}/show", name="curso_show")
* @Template()
*/
public function showAction($id)
{
$em = $this->getDoctrine()->getEntityManager();
$curso = $em->getRepository('GitekUdaBundle:Curso')->find($id);
if (!$curso) {
throw $this->createNotFoundException('Unable to find Curso entity.');
}
$deleteForm = $this->createDeleteForm($id);
// Detalle Formación
$detcurso = new Detcurso();
$formdetcurso = $this->createForm(new DetcursoType(), $detcurso);
return array(
'curso' => $curso,
'delete_form' => $deleteForm->createView(),
'detcurso' => $detcurso,
'formdetcurso' => $formdetcurso,
);
}
In my development enviroment works fine (Mac) but when I go to my production enviroment (CentOS server) I´m getting
The controller must return a response (Array(curso => Object(Gitek\UdaBundle\Entity\Curso), delete_form => Object(Symfony\Component\Form\FormView), detcurso => Object(Gitek\UdaBundle\Entity\Detcurso), formdetcurso => Object(Symfony\Component\Form\Form)) given).
500 Internal Server Error – LogicException
Any clue?
Symfony2 expects a Response object to be returned from a controller action. I’m guessing you probably want something like the following:
The
$this->render()method will render a supplied template name, and in the example above, pass the template your array of parameters. It’ll wrap this generated content in a Response object, which is what Symfony2 is expecting.You can also return a new Response object directly, eg
return new Response('Hello, world')if needed.See the documentation for more details.