Tuesday, September 28, 2010

Tag Cloud plugin for Diem

So I have this Diem based project I'm working on for some time now and at some point I decided I need to display a tag cloud on the page. I thought it will be a trivial thing to add but unfortunately I was wrong. I've searched the symfony plugins database and found nothing, Diem itself doesn't have anything like that as well. So I was tring to find anything interesting outside the symfony community and I found only two (!!) scripts which satisfied my needs.

I'm on Twitter

Yeah, after years of resisting it, I've set up a Twitter account. You can follow me @devFactor. I'll tweet mostly on symfony and web development topics.

Thursday, September 2, 2010

Separating Model from Data Access Layer

At last I found some time to provide you with an example of design I wrote about in previous posts. For the sake of easy understanding I'll keep the example simple but of course in reality it'd be much more complex. This example is based on a real implementation.

Wednesday, August 25, 2010

Symfony and MVC - follow up

My previous post caused a little bit of confusion so I decided to write this short follow up before I find some more time to provide you with an example explaining my approach. In this post I'll clarify some of my previous statements about separating your models from ORM generated classes.

Saturday, August 21, 2010

Symfony and MVC - a little rant about

So symfony is a MVC based framework. True. It provides all you need to build MVC applications. True. Symfony users build MVC applications. Unfortunately - usually not true. And I think it's mostly symfony's team fault. I'll explain it later in this post.

Tuesday, November 10, 2009

The Law of Demeter

Today I've read a very interesting blog post. What brought my attention is thing which bothered me for quite a long time in the past, I mean this:

Most of the Symfony projects I’ve worked on are rife with lines of code like this (in the actions):

$this->getUser()->getGuardUser()->getProfile()->getEmail()

To conform to the above ideals (The Law Of Demeter) the code should be re-written as:

$this->getUser()->getEmail()

My solution for that problem is using magic method __call() in myUser class:

public function __call($method, $arguments)
 { 
  if(is_array($arguments))
  {
   return call_user_func_array(array($this->getGuardUser()->getProfile(), $method), $arguments);
  }
  else
  {
   return $this->getGuardUser()->getProfile()->$method();
  }
 }

It's possible because both tables have 1:1 relationship. This way we basically merge both objects and don't have to create dozens of "shortcut" methods.

Saturday, November 7, 2009

Sympal installation fix

Recently I was trying to install the Sympal plugin for Symfony. Everything was fine until I tried to run the application. Symfony has displayed an 404 error unfortunately telling me nothing useful:

Unable to find the 
Component : Content
Table : content
object with the following parameters "array ()").

I've cleaned the project up and step by step installed the plugin again. And... I saw the same error. So I thought "wtf?" and started googling for help. I thought: it's quite popular plugin, I should find tons of posts and manuals about it. I was wrong, I found only few posts about my problem and no solution. I didn't give up and in the end on some mailing list someone found the reason and was kind enough to share it.

It looks like there's a bug in fixtures: in content and menu_item tables all records have the date_published column set to NULL while the is_published flag is set to TRUE. So to fix the error set date_published=NOW() and run the app. Now everything should work as expected.