// Symfony 2
public function updateAction($id)
{
  $em = $this->getDoctrine()->getEntityManager();
  $product = $em->getRepository('AcmeStoreBundle:Product')->find($id);

  if (!$product) {
    throw $this->createNotFoundException('No product found for id '.$id);
  }

  $product->setName('New product name!');
  $em->flush();

  return $this->redirect($this->generateUrl('homepage'));
}
# Django
def updateAction(request, id):
    product = Product.objects.get(pk=id)
    # Product.DoesNotExist exception raised if not found
    product.name = u"New product name!"
    product.save()
    return HttpResponseRedirect(reverse('homepage'))

6 Comments on “The more Symfony2 learn, the more I like Django”

You can track this conversation through its atom feed.

  1. Schneck says:

    The title could also be “The more PHP-Frameworks I learn, the more I like Django”

  2. Carlos Escribano says:

    True, but I must admit that of all the frameworks I’ve tried, Symfony2 is the best. We are using it for the new version of Siwapp but is a big effort to learn how it works!

  3. Carlos Escribano says:

    Definitely I like Django more than Symfony. I think the problem is the complexity of Doctrine and its tight integration with Symfony. Once upon a time an ORM that was powerful and not so complicated called Doctrine…

  4. Carlos Escribano says:

    Of course, if I need a PHP framework I will use Symfony.

  5. Alvaro Marcos says:

    Hi,
    We were on the road to symfony2 siwapp. Is there any work in progress? WE would like to collaborate.
    Thank you in advance…

  6. Carlos Escribano says:

    Álvaro, puedes acudir directamente a y unirte a los grupos de Google de usuarios y desarrolladores (sobre todo este último) y si ves que puedes aportar código, ideas, etc… adelante.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>