Tuesday, August 18, 2009

cakephp vs symfony vs django admin site: why i chose to not choose the "best"

Recently I had to choose a framework to implement a web data entry application (dozens of forms and database tables). I looked for a rapid application development environment that does code generation for basic administration tasks (CRUD trough web forms) so I first discarded all the frameworks that does not have such a functionality: codeigniter, kohana, zend framework.

I neither want to use Ruby on Rails because i know PHP pretty well and, having a moderate understanding of python too, I didn't want to learn another language.

My research ended up comparing the code generation features of these three frameworks:

  • django

  • cakephp

  • symfony



I've used cakephp in the past for a couple of small projects, and, imho, it's a nice framework with some limits:


  • cakephp generates code for models, views, controller and templates. merely this code is customizable only modifying the already generated sources, so if you change something in your database you cannot just re-generate the admin interface because this will overwrite all of your customization

  • i don't like cakephp "convention over configuration" philosophy. expecially i don't like the fact that I must fight against the pluralization of model names which are by default inflected in english (that's not my language as you can guess)

  • no filters at all (ie. date range) are produced by the CRUD generator

  • development is very tight to the construction of models. it's not easy to implement something outside the mvc pattern (which is good for somebody but not in my case)



Once stunned by django admin generator I considered to use this amazing framework which has some very good points over symfony (the last framework I tried):


  • django it's very fast

  • the killer feature: django does not have code generation, it simply creates its admin site "on the fly" introspecting the models and the Admin classes. everything is magically reflected on the admin site without manually invoking some nasty cli command every time you change something.

  • django admin site has a nice clean design with calendar javascript widgets for dates and times

  • symfony+doctrine admin generator ships with ugly selects for date widgets and an ugly default admin theme

  • django admin site has a dashboard (a page with a list of all your models and a link to the common crud operations) with a list of the latest actions

  • django has a configurable automatic formsets generation to edit multiple entry of related data (ie. you have a book form and several categories text fields in the same page).

  • symfony comes with a similar functionality (called embedded forms) but they are harder to manage and there's no support at all in the admin generator

  • django admin site CRUD keeps revisions and records actions automatically (with symfony you can use a doctrine/propel behaviour for version history but I never tested it)

  • django syntax for ORM and database querying is just perfect

  • symfony default ORM (propel) has an insane syntax to cope with (Doctrine ORM is simple anyway and fun to code with)

  • django directory structure could not be simpler: you have a directory per module and everything is contained there (usually you have just three files for each module: admin.py, models.py, views.py) apart from templates

  • symfony module generation acts like a bomb dropped on your filesystem. it spreads files everywhere (filters, forms, modules, models, templates, actions, base classes, a dozen of yaml configuration files) and it's not easy, expecially for beginners, to understand what does what and where it is located (the worst thing is that the cli truncates the paths in the console output when the creation process is running, so you have to figure out yourself where everything's gone)

  • i was diffident about symfony YAML and configuration files



Finally, I explain why I ended up using symfony and not django for my project.


  • I'm more skilled with php than with python.

  • A huge limit of the admin site in django is that it does not have a "view" permission on models. You can assign "change", "delete", "create" rights on objects but the django developers think that admin users that can "view" something then automatically have the right to modify it.
    I find this absurd (I also wrote a trac ticket about this).

  • With django I haven't found an easy way to have a "dynamic" owner-like permission (something like row level access with symfony). There are a couple of plugins for this, but I feel they don't really adapt to the scope.

  • Let me say django admin filters are bad for your health. I wonder why an admin filter must be constrained to a multiple choice. What if I want to search with a __custom__ date range or a custom string ? Symfony has these two gadgets in the generator.

  • Once you get used to YAML, symfony generator.yml becomes your closest friend. I like the level of customization that you can reach editing that single file.

  • Symfony cli provides some extras out of the box: db migration (django has an external plugin called evolution), remote deplyment sync with rsync, etc.



My final opinion:

  • cakephp is a good, fast, relative small framework (well i know code igniter is faster and smaller but it does not have code generation). It's fun to work with it and easy to learn. The documentation has reached a good level.

  • django probably will be the best framework in the world, I'll use it when I've mastered python

  • symfony is the most complete php RAD out there that ships with code generation (if you relax this constraint I think that Zend Framework comes first) but it has a steep learning curve

7 comments:

Dustin said...

Django is the best framework in the world. I chose to use it over all the PHP framework despite the fact that I had zero experience with Python and 10 yrs experience with PHP. It's been two years now. I still consider myself a Python noob, but I think Django/Python is the best decision I have made when it comes to web development.

andy said...

For the record there are workarounds for all your issues with the Django admin. View permissions and row-level permissions are fairly simple to implement.

You can customize the list_filters that django provides either by subclassing the admin template and adding your own markup or by writing your own custom filterspec.

Actually I wouldn't even call them 'workarounds'. The django admin is designed to be extensible so these are just customizations for your specific requirements.

Tejuteju said...

Thank you.Well it was nice post and very helpful information onRuby on Rails Online Training Bangalore

Anonymous said...

En Son Çıkan Perde Modelleri
SMS ONAY
mobil ödeme bozdurma
nft nasıl alınır
ankara evden eve nakliyat
Trafik sigortası
dedektör
web sitesi kurma
aşk kitapları

hacklink said...

Good content. You write beautiful things.
taksi
mrbahis
sportsbet
sportsbet
hacklink
vbet
mrbahis
korsan taksi
vbet

cenk said...

dijital kartvizit
referans kimliği nedir
binance referans kodu
referans kimliği nedir
bitcoin nasıl alınır
resimli magnet
3UW

burak said...

hatay
kars
mardin
samsun
urfa
1GSFAG

Post a Comment