An introduction to Doctrine

I recently applied for a new job as a web developer due to my 2012 plans involving moving to the city and working in a more corporate environment. After a technical interview over the phone mainly relating around PHP, MySQL and some general OO questions the interviewer finished by telling me more about the company. When he told me they specialise in Drupal development and use Doctrine for some in-house software and development I decided I better go do some research.

Downloading and Initial Configuration

The documentation seemed to recommend using PEAR for installation but I didn't have much luck getting that to work and to be honest I didn't try very hard. I simply went straight to the manual configuration and it was painless to say the least.

Some pre-requisites

I'm working on my Mac using OS X Lion and I have already installed MAMP so I have a working apache server with full PHP support. PHP is also available on the command line in OS X.

Setup Steps

  • Download the latest Doctrine ORM archive. I used 2.1
  • Extract the Doctrine folder to your desktop. You should have something like "DoctrineORM-2.1.5"
  • Create a directory on your local web server. e.g. /htdocs/project
  • Move the DoctrineORM-2.1.5/Doctrine directory to /htdocs/project
  • Move DoctrineORM-2.1.5/bin/doctrine.php and doctrine to /htdocs/project
  • Head over to getting started with Doctrine and follow the tutorial. I'll ensure you it's fun.

Problems I encountered

Just the one. I kept receiving the error related to 'date.timezone' when accessing and creating objects with a DateTime property. I simply added this line to my bootstrap.php file.

date_default_timezone_set('UTC');

Some more thoughts

I don't want to comment to much about an ORM that ive used for less than a day but my initial impressions are that Doctrine could be a real time saver for development. I like the way they highly encourage encapsulating your class properties and public properties will even cause you problems when retrieving objects via primary key. The way objects are mapped seems very intuitive and the annotation schema is great. You can simply comment your classes and Doctrine will create your database schema. I'm not sure how this will compare to the XML and YAML options in larger projects but for now I'm going to stick with it. Overall my first impression is a thumbs up but who knows what future developments will unravel.

As always if you have any problems with installation then leave a comment.

Comments

I don't have a Drupal website, aguhotlh I look forward to hearing more about them at BootCamp. But getting some basics of design that might apply to more than just Drupal is something that I could definitely get behind.

Add new comment

The content of this field is kept private and will not be shown publicly.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.