Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine where exact use 1.2 version and 2.0 Version?

Tags:

php

doctrine

What is difference between Doctrine 1.2 and 2.0, how to choose between them.

like image 514
Ikon Avatar asked Dec 21 '22 15:12

Ikon


1 Answers

Doctrine 2

  • it's the recommendend version
  • ships with symfony 2.0
  • faster than 1.2
  • no magic methods
  • uses entity manager (datamapper like)
  • components are loosely coupled
  • requires PHP 5.3 (uses namespaces)
  • relative new project

Doctrine 1.2

  • easier to learn
  • works with php < 5.3
  • ships with symfony 1.3 / 1.4
  • magic methods (ActiveRecord like)
  • mature and tested project
  • less typing

Doctrine 2.0

$user = new User;
$user->setName('Mr.Right');
$em->persist($user);
$em->flush();

Doctrine 1.2

$user = new User;
$user->setName('Mr.Right');
$user->save();

To summarize, imho Doctrine 2.0 has a steeper learning curve even if it performs better (clever use of transactions). I find ActiveRecord persistence model and magic methods rather clumsy so I'll go with the 2.0, but this is my personal opinion, Doctrine 1.2 is still very good (expecially with small projects where the 2.0 could be overkill)

see also

Doctrine 2.0 ready for use?

Datamapper vs ActiveRecord

like image 61
gpilotino Avatar answered Dec 24 '22 05:12

gpilotino