Every once in a while, I get into an argument about extending PHP’s Traversable interface instead of theĀ Iterator interface in custom interfaces. The confusion seems to result from the official documentation of Traversable. Let me clarify why you should give Traversable much more love than you do right now.

Read the rest of this entry »

6 Comments | Category: Best Practices

Stumbling over a post in the symfony-users list I wrote down some information on how we manage mobile sites in our ullright platform:

There’s an old blog post about creating an symfony iPhone view:
Most of it is still valid and it works.

But there is one serious drawback: You have to provide a mobile template for each action.
That’s why we created a tiny patch to provide a fallback to normal templates in case there is no special mobile one.

Here are the required parts:

Mobile detection: This belongs into your project configuration:

Symfony patch enabling fallback to html templates: (Patches sfView.class.php)

Finally provide a mobile template (or not):
Normaly you would put your template in apps/frontend/modules/myModule/templates/myActionSuccess.php
Now you can provide a mobile template by creating the following file: apps/frontend/modules/myModule/templates/

This also works for layouts, partials and components. Example: apps/frontend/modules/myModule/templates/

Here’s the original post:

Have a nice day!

5 Comments | Category: Best Practices

Although most modern literature agrees that testing is essential for successful software projects, testing has to be done right. Several bad habits can be identified that not only negatively affect testing performance, but also reduce your development speed. One of the first mistakes people make when they first discover testing is trying to reach 100% code coverage. I was no exception. Read the rest of this entry »

5 Comments | Category: Best Practices

Unit testing can be a blessing and curse at the same time. Once you start doing it on a regular basis, it can become an addiction. You test everything, you feel the satisfaction of 110% test coverage giving you confidence in your code. But after a while, testing suddenly seems to slow you down. Everytime you make a change in your code you have to adapt several unrelated tests. Adding a <ul>-tag to your template becomes a matter of minutes, rather than seconds. And, worst of all, your test suite is slow.

What happened? Read the rest of this entry »

13 Comments | Category: Best Practices

The “default” context does not exist.

Is there any symfony developer out there who never stumbled upon this dreadful error message? I doubt it. Recently, a lot of posts have been made on the user mailing list asking for explanations and fixes. A quick search on Google for the exact phrase even returns 480 results!

The reason for this error is quite simple though: It’s because you used sfContext::getInstance(). And you should never do that. Read the rest of this entry »

23 Comments | Category: Best Practices

Additional Resources