/** * @Route("/savePerson") */ public function savePersonAction(Request $request) { $firstName = $request->request->get('firstName'); $lastName = $request->request->get('lastName'); $address = $request->request->get('address'); $zip = $request->request->get('zipCode'); $city = $request->request->get('city'); $country = $request->request->get('country'); $email = $request->request->get('email'); $person = new Person(); $person->setFirstName($firstName); $person->setLastName($lastName); $person->setAddress($address); $person->setZip($zip); $person->setCity($city); $person->setCountry($country); $person->setEmail($email); $em = $this->getDoctrine()->getManager(); $em->persist($person); $em->flush(); $response = new JsonResponse(); $response->setData(array('response' => 'Created person entry with id ' . $person->getId())); return $response; }