Refactoring a controller in Symfony

When you first start using Symfony you will probably start with the code examples from the official documentation. This is fine and much recommended and I would encourage anyone to do so. These examples are amazing to get a good start in Symfony and provide quick feedback.

After a while though, you should consider to write cleaner and more separated code. Having well structured code will help you immensely to reuse code and write tests.

Continue reading “Refactoring a controller in Symfony”

Why I understand you are using ‘continue’ and why you shouldn’t

Recently I had to help out on a colleagues project, which I was not that familiar with.

First of all this ment to work the code and get a general understanding of what was happening. So after a while I found the spot where I had to put my changes. Implementation was done quickly enough and I was on my way testing.

First test didn’t give me anything. “Hmm.. this should work.. why am I getting no emails?”
Second test didn’t work the way I expected as well “Is my email sending broken?”
The third test was about my general ability of sending and receiving email. At least something was working the way I expected.

So it had to be the general function I was working at and naturally, revisiting the code brought the problem to light. My colleague used a rather cheeky way to abort the foreach loop, which prevented the function from ever reaching my newly implemented lines of code.

This is what I found up the lines:

Continue reading “Why I understand you are using ‘continue’ and why you shouldn’t”