How to force symfony colors on windows with PuttyCyg?
Those of you who’re developing with symfony under windows will have noticed that, when running tasks in the command prompt, no colors are used. This is because the windows command prompt isn’t compatible with the color notation.
Most of you also have cygwin installed (shame on you if you didn’t :p). But even if you run the tasks through “PuttyCyg”, which is fully compatible with the color notation, you will not benefit from the colors.
Why?
Interview: Stefan Koopmanschap

A few weeks ago I thought it might be cool to get some interesting guys, which are occupied with projects in PHP, interviewed. And guess what, we got on contact with Mr. Stefan Koopmanschap and he was kind enough to answer all our questions.
Stefan Koopmanschap ('left') is a PHP developer, consultant and trainer with an eye for best practices. He works at Unet as (symfony) developer and development team leader. He is a community person and is active in the european PHP community as secretary of the phpBenelux Usergroup as well as in the Symfony community by advocating symfony and as the Community Manager.
Stefan has a wide history in Open Source, having been Support Team Leader for phpBB, documentation translator for Zend Framework and community manager, plugin developer and maintainer plus various other things for symfony.
Stefan is also a best practices advocate. He prefers easy and useful explanations of best practices over the academic and theoretical stuff found in most literature.
Hope you enjoy this interview!
Hello Stefan, first of all, thx for taking the time to answer all our questions.
Can you tell us what projects you are currently working on?
At work I am involved in a big project to build an application that will handle all the administration, provisioning and handling of user accounts etc. for the whole VOiP and connectivity of the services we offer. Aside from that, my main projects are being the Community Manager for symfony and also preparing some new talks for the upcoming conferences.
new PHP meeting
PHPBelgium is pleased to announce our first meeting in Mons!
The event will be recorded and available in live streaming on this url: www.isims.be/phpbelgium.html
If this link wouldn't work, more information can be found on the website of CampusNumerique
Schedule:
19:30h Welcome & drink
20:00h PHP & the MVC Pattern - Patrick Allaert
Patrick Allaert is Competence Center Architect at AUSY where he brings 10 years of PHP development experience. Patrick is also known by the community for developing APM as well as evangelizing for Free and Open Source Software
21:00h Break
21:10h PHP 5.3: new features - Davide Mendolia
Davide is a veteran PHP developer working at AUSY as a PHP Software Architect. In his spare time, Davide works on APM too as well as contributing to the PHP project with benchmarking tests
22:00h Quizz to win goodies/conference tickets
22:15h Socializing and networking
Mantis in Eclipse with Mylyn
This is a post especially for those who use Mantis as a bug tracker software and Eclipse as development software. For our PHP and JAVA development we do all the programming in Eclipse and wouldn't it be easy if Eclipse recognized the bugs we are working? Wouldn't it be easy if we could just get an automatic link between mantis and the commits we do in subversion (svn).
Well, praise the lord, 'cause there is an open source project out there that does all these things called Mylyn.
Mylyn is a task-focused interface for Eclipse that reduces information overload and makes multi-tasking easy. It does this by making tasks a first class part of Eclipse, and integrating rich and offline editing for repositories such as Bugzilla, Trac, and JIRA. Once your tasks are integrated, Mylyn monitors your work activity to identify relevant information, and uses this task context to focus the user interface on the task-at-hand. This puts the information you need at your fingertips and improves productivity by reducing searching, scrolling, and navigation. By making task context explicit Mylyn also facilitates multitasking, planning, reusing past efforts, and sharing expertise.

After a quick install and doing the configuration in Eclipse the interface is installed in Eclipse and ready to work with. And it is great! Easy overviews of all the bugs sorted by filter as you personally prefer, great layout to create and manage the bugs, etc.
It communicates quite nice with mantis, it could be a bit faster but let's not fall over that tiny thing. The cool thing though is when working for a specific bug, all changes will be committed on those files with a reference to that specific bug. This makes it very easy to get see what files where changed for a specific bug.
For example when you commit changed files you will be asked to comment your committed files. Mylyn links your files directly to the current bug you are working on and puts this in the comment area: "fixed issue #178: Change user name to full name" . The number of the issue and the state are first mentioned and the title completes your comment.
In the screenshot you can see how a bug can be inserted or edited in a easy layout and inside the eclipse environment. Click on the image or here to see a larger image

My colleague Toni also installed WebSVN that gives us a super overview on all those changes and files committed in subversion.
If you use Mantis and Eclipse and SVN I highly recommend that you use these two utilities.
TestFest 2009
Tomorrow on the 9th of may an event called 'PHP TestFest 2009' will take place in the offices of Combell. (visit the website)
What is TestFest you ask?
The TestFest is an event that aims at improving the code coverage of the test suite for the PHP language itself. As part of this event, local User Groups (UG) are invited to join the TestFest. These UGs can meet physically or come together virtually. The point however is that people network to learn together. Aside from being an opportunity for all of you to make friends with like minded people in your (virtual) community, it also will hopefully reduce the work load for the PHP.net mentors. All it takes is someone to organize a UG to spearhead the event and to get others involved in writing phpt tests. The submissions will then be reviewed by members of php.net before getting included in the official test suite.
This event will take place in different countries but for the dutch speaking PHP community you can go to these addresses:
Hogeschool Domstad, Koningsbergerstraat 9, 3531 AJ Utrecht,The Netherlands
And
Combell offices Ghent, Skaldenstraat 121, 9042 Gent, Belgium (more info)
There will be a workshop to get the needed information and then it's your turn to contribute to the development of the PHP language.
Felix De Vliegher is the mentor for Belgium and did the most tests in 2008 in the whole freaking world. With his experience and vision, this will be a piece of cake, be there or be square.... (maybe I will write about Felix later in our topic interesting people)
For those who will be on this event, have fun!!!!
Symfony Form: unsetAllFieldsExcept()
When creating forms in symfony which extends from a Base (ORM) class, you sometimes do not need all fields that Propel/Doctrine generates for you. If you want to remove them you have several ways to do so.
1. Unset the fiels you don't need.
public function configure() {
unset($this['field1'], $this['field2'], ... );
}
Simple way to remove the fields you don't want, but if you change something in your database, which has an impact on that form (new column, foreignkey, etc ), it will be added in the (generated) super class. And if you don't update the unset function with that extra field, it will be expected in the form. Unless you have unit tests for all your forms this could brake it without knowing it.
2. Override the setup function.
/**
* @override
*/
public function setup()
{
parent::setup();
$this->setWidgets(...);
$this->setValidators(...);
}
Another way is to override the setup function and do your own widgets and validators initialization. This is a good way to only intialize the fields you really need, but you'll have to do what your ORM generated for you.
3. Use a function which unsets all fields except the one you need (like the enableAllPluginsExcept function).
$this->unsetAllFieldsExcept(array(
'field1',
'field2',
'field3',
...));
This would be usefull, because it will remove all fields you do not want to use, and even if new fields are added it will not use them. The drawback is that if you have 20 fields and only need to unset one of them, you'll have more type work
.
Since it does not exist in symfony, I quickly created our own function. This function should be added in the class BaseFormPropel.class:
abstract class BaseFormPropel extends sfFormPropel
{
public function setup() {
}
protected function unsetAllFieldsExcept($fields = array()) {
$unsetFields = array_diff(array_keys($this->getWidgetSchema()->getFields()), $fields);
foreach($unsetFields as $value) {
unset($this[$value]);
}
}
}
Which one to use ?
None of them are better. But if you need to reset a majority of the fields the ORM has generated then I would go for the method 2. If you only need to unset the fields you do not want to use then I would use the function unsetAllFieldsExcept().
Which method do/would you use ?
A few helpful PHP date methods
For a lot of people dates in PHP are an issue, and the PHP functions aren't sufficient enough to do all converts you need.
Therefore you find a few easy PHP date conversion methods. Feel free to add your own methods or requests in the comments as we know that these methods don't cover everything. You can see it for yourself when you read the rest of this entry:
- get start and end date for the next two months in an array
- get the datetime for a specific user culture in Symfony
- get all days between a given start and end date and return it in an array
- get the difference between two dates
PHP DOMDocument: Convert Array to Xml
Recently I start working on an export module to invoice applications. One of them uses a very simple xml structure (simple nodes without attributes etc.) and therefore I wanted to create this xml also in a very simple way: from an array.
I decided the use DOM, and not e.g. SimpleXML, because I need to validate my xml with a schema.
After a quick search on the internet I found several snippets that could do the trick until I had to set the same element tag name on the same level:
<nodes> <node>text</node> <node>text</node> </nodes>
The snippets I found use the index of an array to create the name of the element and the value for the text part. Only everyone knows that you cannot set 2 keys with the same name in an array.
So what could we do to improve this ?
Symfony Forms Framework: Merge 2 forms
Recently I had to create a form to create/update users in our system. Some time ago we decided to save are users in 2 tables. The first table would contain all login information and the second his personal information. This is a simple example of the DB design:

User db design
I would not recommend doing this for so little fields. But in our system we have a lot more fields, and it helps us to optimize our queries.
Wouldn't it be better if we could merge the 2 forms? The answer is yes. And it's pretty easy to do so in Symfony ... too bad that it’s not documented on the Symfony website.