Thursday, December 20, 2012

Solution: Crack the code (Dead Trigger code-puzzle)

Since the contest is over, it is time for me to reveal the way I figured out to solve the code.


Wednesday, December 19, 2012

Crack the code (Dead Trigger code-puzzle)

One of my favorite mobile games (Dead Trigger) recently launched a challenge. You can find a code in there game and the first 10 to decrypt it will receive a T-shirt. Before I share the solution with anyone, I'd like to give you a chance to crack the code as well:


Good luck all.

P.S. Just got the confirmation I was lucky to be among the first 10 :-). I'll post a picture of the shirt as soon as it comes in.

Friday, December 7, 2012

Bundle for faster generation of entity dropdowns for Symfony 2

Soon after writing my previous blog, where I described a way to speed up the rendering of entity dropdowns, I received lots of feedback about better and nicer ways of doing this. All the suggestions where the same: use a custom form type and a datatransformer.

So I did for one entity, but I didn't feel like doing it for every entity. So I wrote a console command that allowed me to do this automatically (for one or all entities within a bundle).

After a short discussion with my boss, we agreed upon releasing the generator to the public and today the day is here.

The bundle is located at and can be installed via composer. For all the details please take a look at

Oh and feel free to say thanks to my boss (Martijn) in the comments, for allowing me to opensource otherwise proprietary code.

P.S. This is my first time releasing code using composer, so please report any bugs you might run in to on GitHub:

Thursday, November 22, 2012

Speeding up the rendering of entity dropdowns in forms in Symfony 2

Update: See for an improved implementation.

One of the great features of Symfony 2 is the simplicity of rendering a form, even when you're using external entities. The only problem is that rendering a dropdown with 3662 entities is quite slow. In my case this took almost 2 seconds!

Wednesday, November 21, 2012

How to time your own events in Symfony 2?

As some of you might have noticed by now, I am quite interested in the performance of my application. Since Symfony 2 has such a great profiler I was looking for a way to time my own code within the existing profiler and without writing to much code.

Monday, November 12, 2012

Did KnpPaginator just break?

I just updated my symfony using Composer (which also updated my Doctrine etc). All of a sudden I now get the error 'Invalid parameter number: number of bound variables does not match number of tokens'.

I was able to fix this by making a change to /vendor/knplabs/knp-components/src/Knp/Component/Pager/Event/Subscriber/Paginate/Doctrine/ORM/QuerySubscriber.php

Why does the Symfony 2 firewall take so long to load?

During the development of my current project, I noticed in the profiler that the Firewall took about 1 second to load, which was more than 50% of the total load time.

Wednesday, September 12, 2012

Using ACLs and ACEs in Symfony 2

Symfony 2 has a couple of pages on how to use Access Control Lists (ACLs) which only describe how to create an Access Control Entry (ACE), but not how to maintain (update/remove) them.

The updating/removing of ACE's is a bit harder than creating a new one. Therefore I just wanted to share a simple example. This code comes from a UserController where a User object can be assigned to one or multiple companies which (s)he should be able to manage.

Symfony 2 and the case of the missing ROLE_PREVIOUS_ADMIN role

In the Symfony 2 manual there's a small part about 'Impersonating a User', which talks about how you can switch between users if you are an administrator. After following the steps, as discussed in the manual, I wanted to find a way to see if the current logged in user was an impersonation, or the real user. After searching on Google for a bit, I found a couple of posts (1, 2, 3) that all described that the impersonated user should have the role 'ROLE_PREVIOUS_ADMIN'. But for some case my impersonated users did not have that role.