My biased view on Doctrine vs Propel

I’m getting old and I’m old fashioned.

I’m still using mysql, not mongoDB.

I’m using php and apache, not node.js, ruby, python or lighttpd, nginx or ….

And I’m using propel again (1.5), not doctrine. AND I’M LOVING IT!!

After #sfdaycng 2009, the presentations and talks there, I forced myself to giving Doctrine a try and really liked it then. A lot of reading through documentation in the beginning if you are new to it, but hey, that’s normal. However, today, even when writing a simple query, I still have to consult the docs. Why? The syntax seems not to be “my style” somehow, it won’t fit into my type of writing code.

But there is such a HUGE difference between Doctrine and Propel and Doctrine is SO MUCH BETTER

Is it? Do I care what’s inside if I’m only querying a database without using all possibilities? Remember sfLive 2010?

“Is Doctrine re-inventing propel” Hahaha LOL ROFL LMAO

At this years big symfony conference #sflive2010, in a Q&A session about Doctrine2, a poor guy obviously asked the question, that made it into a big running gag: “Are you trying to re-invent propel?”

I have to admit and regret that I was not there, but if you followed the #sflive2010 hashtag on twitter, it was not very long until this got tweeted over and over again. And everybody was making fun of it…

Sure, it is kind of funny to ask @jwage, (lead) developer of Doctrine that question… But hey? What’s really so funny about it?

While everybody in the audience laughed, it really would have been interesting to

a) see how many were trying to smirk, wondering whats so funny about that

b) know how many would have been able to give a good reply on that?

And with “good reply” I mean, explain the difference.

And with “difference” I mean, explain it beyond

  • “doctrine has the schema.yml and the model classes in a subfolder”
  • “propel uses two classes User and UserPeer, doctrine has User and UserTable”
  • “propel has a criteria object, doctrine a query object”

If you started with symfony 1.0 as a developer that did not work with frameworks like symfony before (like I did), everthing is “symfony” – may it be propel, phing, creole, PDO, … and getting into these differences was not really worth it in the first place if you wanted to get started with writing your first applications.

What I’m trying to say: I guess that a lot of symfony developers out there don’t know or care about “Doctrine” vs “Propel” – they use the default. And they call it “symfony”, thinking that it belongs to it. If they started with symfony <1.2, they’ll use propel, now they use doctrine – because it’s the default. You learn it, you use it, you stick to it.

And I sticked to propel throughout 1.2. And it was quite save for me getting along ignoring Doctrine. Just then, when I started using Doctrine after #sfdaycgn I found new things, new approaches, things I liked, things I had to learn and a lot of stuff I could not get the hang of.

So now, with propel 1.5 and the new Query objects, I gave it a try and was so excited, I decided to come back to Propel. Just because it “feels like home” and fits my personal style of thinking/coding.

And of course both ORMs have their features and behaviours and at #sfdaycng Doctrine had more of them and so on… But I also assume that a lot of those features are beyond most everyday developer’s needs

But Propel is dead

Oh no, it’s not!!!

With the new 1.5 it REALLY got amazingly easy to write your code, extend your Query Model and easy query creation. 1.6 is on it’s way and 2.0 was just recently announced to be based on Doctrine2, as a layer on top, providing the usability features… that’s something we will have to wait for, but I does sound very good.

But Benchmarks show that…

So what? I couldn’t care less. Why should I? I am not running sites that have gazillions of users with quadrubillions of tables and hexafoobarillions of rows – I don’t care if grabbing all posts with a certain topic and tag for a given user takes 111 ms or 132 ms. But I do care if I have to consult the docs for writing that query because I couldn’t remember the syntax or – on the other hand – my IDE (yeah, right, eclipse, I’m REALLY old fashioned) nearly automagically creates the query for me.

But what are you actually trying to say?

  • Most developers don’t need benchmarks to find their ORM – it’s about own style and preference (or customer specs, but thats another story)
  • Some symfony developers might not even have thought about giving “the other one” a try.
  • Personally, I get along with propel 1.5 better
  • I’m getting old

So, if you know Doctrine, give Propel 1.5 a try.

If you only use Propel, give Doctrine a try.

And if you still use Propel 1.4 – MAN!!! Get the 1.5!!!

Any comments appreciated, I really like to see what I’m missing

PS: I’m even more old fashioned: I’m using vi – not vim, but eclipse with the vi plugin. Why? REAL code completion! A wonderful thing with propel 1.5!

Automated tweets now there is OAuth? Sending Tweets from PHP Command line

For quite some time I’ve been using a scheduled php script to automatically send twitter updates (tweets) to my own account.

Since it was very easy and convenient to do this with the so called basic authentication, I used/modified the simple script provided by Fabien Potencier.

NOW, BASIC AUTH IS GONE!! (Correction: See Update below)

It was long announced, but since September 1st, they really switched it off and this method does not work anymore because now there is only OAuth.

The “strange” (and more secure) thing about OAuth is, that you allow an application to do something with your twitter account, but you do not give out your credentials to the application, you just grant permissions. In most cases, when you are browsing the web, this makes sense if a third party application wants to do something with your account. But in my case, there is just ME, MY TWITTER ACCOUNT and MY PHP SCRIPT that want to communicate, not a bunch of different users.

So: What do I have to do to make it work again?

Step 1: Officially set up your application in Twitter Apps

On you can and have to define your application with a name, some details and a callback URL. Details on this one later.

Step 2: Get and configure the TwitterOAuth PHP Package

On Github, one of the Twitter developers maintains a package for PHP. Download/git-clone it to your web server. You need to adjust the config.php file in this package with the Consumer Key and Consumer Secret of your newly created twitter application (found int the app details section)

Step 3: Allow authentication from your twitter application to your twitter account

Now that you have the twitteroauth pack on your webserver, you should be able to access it and see the default page with a “Sign in with Twitter” button. If you do this, you will be redirected to a screen you might have seen with other third party applicatios before. Only, this time, it’s yours:

In this case, I want to connect with my @managerator to the application “managerator”, might be a bit confusing. (And please excuse me for using a German UI 😉 )

If you grant access successfully, you can check this in you Twitter account’s Connection details on

Step 4: Use the connection

Now that we have connected application and account, how can we send a tweet from the application to the account?

Check the “index.php” file in the twitteroauth package and you will see, that it loads/requires the necessary php files and afterwards does some API calls on the $connection. And, using a browser, this works. Of course, only if your browser is athenticated on twitter already (and of course with the account that granted access to the application).

Now, in my case I want to use the command line php (like a cron-job) to send messages. And of course, PHP is not authenticated on twitter. Thus, a simple call to “php index.php” on the command line will fail.

So, how do we get around this??

Step 5: Store the access_token

When you look again at the index.php, you will see

/* Get user access tokens out of the session. */
$access_token = $_SESSION[‘access_token’];

This access token is an associative array that contains all the things you need for further authentication – coming from your current browser session

So, simply var_dumping the access_token from your browser session and pasting the details into your code like this

/* Get user access tokens out of the session. */
//$access_token = $_SESSION[‘access_token’];
“oauth_token_secret”=> “***************************************”,
“user_id”=> “************”,
“screen_name”=> “managerator”,

Will make your code callable from the command line.

Note: user_id and screen_name is not used, it’s just part of the token


This was a quick hack of my way to get the auto-updated management bullshit tweets working again for @managerator. It’s not very nice, but it works for the time being.

And I hope it helps you, too!

Comments appreciated!!

Update Sept 14th:

Basic Auth is only gone for everbody else but own twitter apps.

As I read on this article you can circumvent OAuth and still use basic auth by adding “?source=twitterandroid” to your API URLs… That’s lame, Twitter!!!

Just tested and verified it, as of today, Sept 14th.