Doctrine vs Propel

UPDATE: Here is a great comparison for these ORM’s for the 2.x versions. Thanks to @Pati for sharing the link.

A quick comparison for the most 2 well known and best ORM‘s for PHP.

Here we will try to make a quick comparison about the most known ORM for PHP. To help developers to take the right decision when we need to decide what is the best ORM which could best adapt to our projects.

These 2 more used ORM are as the post title mentioned Doctrine and Propel.


Both ORMs have many similar basic features, they support all the usual operations for CRUD (Create, Retrieve, Update and Delete), from create a new record to update existing ones. Also, both can generate the PHP classes for you, Propel based on XML while Doctrine based on YAML, And another cool feature they have is that both support different database engines (like Mysql, Oracle, MSSQL, etc).

Both support data validation and model relationships. Additionally, they support simple inheritance, although in Doctrine is called concrete inheritance. Doctrine supports 2 types of inheritance: Simple, where all the classes have the same columns, and the Aggregation inheritance, where we store an additional value in the table which allows us the automatic instantiate of the right model type when we make a query.

Well, we saw they almost share the same features so far, but the following are features only Doctrine has.

Behaviors: Doctrine supports many “behaviors” for its models, for instance, a Timestampable model will automatically create two columns: created_at and updated_at, where we can store the creation and update dates.

Searching: Doctrine has a fulltext search engine.

Plus, Doctrine supports data fixtures and migrations, caching, events, pagination, commands line interface and so on, and we can say in advanced features Doctrine has an advantage compared with Propel.



One of the most important thing is documentation of course. Without a good documentation is hard to use any library. Until the last year (2009) the Propel documentation was one of the major problem for them, and it’s true they are improving it there still are work to do. In the other hand, the Doctrine documentation is great and the community is continuously improving it. So, about documentation concern, Doctrine is clearly the winner.

Libraries Use

The first task we have to do with both ORMs is to build the model classes. Doctrine allows us to just write a simple YAML file, or just PHP code if you prefer it. The Propel proposal is to write a XML to define our model classes, and in my personal opinion I prefer to deal with YAML instead of XML, so point for Doctrine :-).

Database operations

The basic operations with CRUD are very similar in both ORMs, however, there is a big different when we need to do more advanced queries.

Propel uses a Criteria/Peer proposal:

$c = new Criteria();
$c->add(UserPeer::ID, 10);

//SELECT all "User" models which have 10 as their ID and join all foreign tables.
$users = UserPeer::doSelectJoinFoobar($c);

Doctrine proposal is to use Doctrine_Query and a simple customized SQL named DQL (Doctrine Query Languaje):

$items = Doctrine_Query::create()
    ->from('User u')
    ->where(' = ?', 10)

To set values in our model classes these ORMs utilizes different methods: Doctrine uses magic methods, while Propel generates setters and getters. This feature gives to Propel the advantage of autocompletion in most IDEs.

As conclusion I can say that both ORM are great, but I prefer Doctrine. And, of course, you can put the ‘My opinion’ label to this post.

And in this link you can find a comparison that Symfony made between these 2 ORMs.

HTTP Errors

A list of most known HTTP errors.

These errors belong to the HTTP/1.1 standard and they are classified in five different types.
The five different defined types are:

1xx. Informational. The request is received and it continues with the process. The errors in this range indicate provisional responses. The Web Servers should not send 1xx errors to the client, except under experimental conditions.

2xx. Success. These errors indicate that the request was received, understand, accepted and successfully processed.

3xx. Redirection. In this range the client should do aditional actions to complete the request. The required action should be carry by the User Agent with no user interaction only if the method is GET or HEAD. The user agent should not automatically redirect more than five times, if not is considered an infinite loop.

4xx. Client Errors. These errors are triggered when the error is in the client.

5xx. Server Errors. The server fails when it looks like the request is not valid or the server is unable to do the request.

1xx Informational.

100 Continue. The server has received the request headers and the client should proceed to send the request body.

101 Switching Protocols. The client asks to the server to change protocols and the server knows if it could do it.

102 Processing. As a request can contain many sub-headers, this could take so much time to complete the request. This error indicates that the server has received and is processing the request, but it does not response that it’s not available yet. This avoids the client to assume that the request was lost.

2xx Success.

200 OK. This is the standard response for a successful HTTP request. The response will depend in the used method (GET, PUT, POST, etc).

201 Created. The request has been completed and the response is that a new resource was created.

202 Accepted. The request has been accepted to be processed, but it has not been completed yet.

203 Non-Authoritative Information. The server has processed the request successfully, but it’s returning information what could be from another source.

204 No Content. The server processed the request successfully, but there is not content to return.

205 Reset Content. It’s identical to 204 error but with the difference of the response requires the client to reset the resource.

206 Partial Content. The server is returning the resource partially. This error is used in tools like wget.

207 Multi-Status. The body of the response is a XML message and it could contain separated status depending in how much sub-requests were done.

3xx Redirect.

300 Multiple Choices. It indicates multiple options for the resource the user is requesting. For instance, it could be used to present different options to video formats.

301 Moved Permanently. The current request and all future requests to the requested resource should be redirected to the given url.

302 Found. This is the most popular redirect error, the HTTP/1.0 requires the client to make a temporal redirect, but the most popular browsers implement 302 error as 303 error. Therefore, HTTP/1.1 added the 303 and 307 errors to distinguish between these two behaviors, most web applications still use the 302 errors like a 303 error.

303 See Other. This error was added in HTTP/1.1. The response for the rrequest could be find in other URI using the GET method.

304 Not Modified. It indicates that the resource was not modified since the last request.

305 Use Proxy. This error was added in HTTP/1.1. Some HTTP clients (like Mozilla and Internet Explorer) do not handle this error properly, mainly due to security reasons.

307 Temporary Redirect. This error was also added in HTTP/1.1. In this case, the request should be repeat it with another URI, but the future requests could use the original URI. In contrast with 303 error, the HTTP method should not be changed.

4xx Client Errors.

400 Bad Request. The request contains wrong syntaxis or it could not be completed.

401 Unauthorized. This error is similar to 403, but it is specifically used when the user can authenticate but the authentication has been failed or has not been entered the authentication credentials yet.

402 Payment Required. This error is reserved for future uses and it’s thinking to be used for applications those make payments.

403 Forbidden. The request was legal, but the server rejects to response it.

404 Not Found. The requested resource is not found, but it could be in the future.

405 Method Not Allowed. The resource was requested via a not allowed HTTP method. For instance, try to process a form with a GET method instead of a POST.

406 Not Acceptable. The requested resource only can generate content no acceptable by the request headers.

407 Proxy Authentication Required.

408 Request Timeout. The server triggered a timeout.

409 Conflict. It indicates tha the request could not be processed due to a conflict.

410 Gone. It indicates that the requested resource is not available anymore. This error should be used when a resource was intentionally removed, although a 404 error could be returned.

411 Length Required. The request does not specify the content length which is a requirement for the requested resource.

412 Precondition Failed. The server does not accomplish with some pre-conditions that the user is requesting.

413 Request Entity Too Large. The request is to big to be processed.

414 Request-URI Too Long. The entered URI was too long to be processed.

415 Unsupported Media Type. The request does not specify none type of media. For instance, the client specifies the requested resource as image/svg+xml format, but the server does not find a resource with that format.

417 Expectation Failed. The server could not meet the requirements in the request headers.

422 Unprocessable Entity. The request was valid but the server was unable to attend it due to some semantic errors.

423 Locked. The resource which is being accessing is locked.

424 Failed Dependency. The request failed due to previous failed requests.

426 Upgrade Required. The client should be changed to a different protocol, for instance to TLS/1.0.

5xx Server Errors.

500 Internal Server Error. It is a generic error message and it’s returned when there is not a more specific error.

501 Not Implemented. The server neither recognizes the HTTP request method nor have the ability to complete the request.

502 Bad Gateway. The server was working as a gateway or proxy and it received an invalid response from the downstream server.

503 Service Unavailable. The server is not currently available (due to an overload or because it’s in maintenance). Generally, this error is temporal.

504 Gateway Timeout. The server did not receive a response in time.

505 HTTP Version Not Supported. The server does not support the HTTP protocol version used by the request.