Navigation

Annotations have become a popular mechanism in PHP to add metadata to your source code in a simple fashion. Their benefits are clear: They are easy to write and simple to understand. Editors offer increasing support for auto-completing and auto-importing annotations. But there are also various counter-arguments: Annotations are written in documentation blocks, which may be removed from packaged code. Also, they are coupled to the source code. Whenever an annotation is changed, the project needs to be rebuilt. This is desirable in some, but not in other cases.

For these reasons, Symfony always committed to supporting annotations, XML and YAML at the same time – and with the same capabilities – to let our users choose whichever format is appropriate to configure the metadata of their projects. But could we take this one step further? Could we build, for example, XML support directly into the Doctrine annotation library?

Read the rest of this entry »

Written by: | 8 Comments | Category: Thinking Ahead

Last week, I read a post by Beau Simensen about resource location in PHP. It was interesting, because I had already pondered over this topic in the context of Symfony2. Thinking about how to make Beau’s proposal work for Symfony2 brought me to a result that hit me like a stone. Both he and Amy Stephen made me realize how much this could change not just Symfony2, but the PHP ecosystem as a whole. After PSR-0 and Composer, this is the next important step to ensure interoperability between PHP libraries. And it could almost completely replace the new and hotly debated autoloading PSR. Let me take a few minutes of your time to explain why.

Read the rest of this entry »

Written by: | 10 Comments | Category: Thinking Ahead

Recently, Aura is creating some buzz that components of PHP frameworks should not have any dependencies. To quote Paul M. Jones’ recent article on Aura:

The distinction is that all Aura packages (with the exception of the Framework package) are completely independent, and have no cross-package dependencies, whereas at least some of the components from Symfony2 and ZF2 have dependency requirements.

Or, quoting this article on replacing Silex with Aura.Micro:

I was recently working on a small project that used Silex. As I browsed my vendor folder, I realized how much extra “stuff” I had inherited with Silex. There were a bunch of other components required when all I wanted was some quick and easy routing, micro-framework style.

I think this needs some urgent clarification before this way of thinking becomes mainstream and PHP creeps back into its NIH-hole.

Read the rest of this entry »

Written by: | 31 Comments | Category: Community

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 »

Written by: | 6 Comments | Category: Best Practices

You are joining the Symfony Live conference in San Francisco this year? Good! I will be giving a talk about the Symfony2 Form component and you have the unique opportunity to vote on what I will be presenting. Today I have put up a survey with 23 topics that may find their way into my talk. These topics include questions such as:

  • How can I access the entity in buildForm()? I want to customize my form based on some property.
  • How do I create a collection field with JavaScripts to add/remove rows?
  • There are so many events, when should I use which one?

Which of these topics I will present is entirely up to you. So please take the survey and help me improve your experience of my talk. Oh, and if you take the survey there will be a prize, and a raffle, and one very lucky person… :)

You aren’t joining the conference in San Francisco? Then I also warmly invite you to participate in the survey. Pretty much one year after the first release of Symfony 2.0 and shortly before the release of version 2.1, we are eager to learn what our users are happy about, what they struggle with and what they would like to see improved, both in the usability and the documentation of the Form component. Unfortunately, you won’t be able to participate in the raffle during the conference, but your feedback will tremendously help us to improve future releases of the framework and its documentation.

Take the survey.

Written by: | 4 Comments | Category: Community

Symfony2 features a brand-new Form component that, to my knowledge, supersedes most existing PHP form libraries in functionality and extensibility (not counting the still lacking, native JavaScript support). It has been in development for  two years, even though I was already thinking about it since 2009 and earlier. It is becoming more and more stable recently, with a first completely stable release expected for Symfony 2.2.

This post was partially triggered by the release of the new Zend Framework 2 Form RFC because I think that a lot of duplicated effort is going on there. I completely understand that Zend Framework 2 needs a form layer that is tailored to the components delivered by the framework. The purpose of this post is to demonstrate that the Symfony2 Form component is perfectly suited for this requirement. Symfony2-specific functionality can be unplugged, leaving only the raw core dealing with form processing and abstraction. As a replacement, functionality can be developed for supporting Zend’s or any other framework’s components.

Creating a generic form library that elegantly solves all the various use-cases that can be found in web form construction and processing has been a challenging, long-lasting and complex task that is not over yet. Cooperating and continuing development from this common base on seems like a big chance to make form handling in PHP more powerful – and easier – than it has ever been before.

Read the rest of this entry »

Written by: | 20 Comments | Category: Development

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:
http://www.symfony-project.org/blog/2008/06/09/how-to-create-an-optimized-version-of-your-website-for-the-iphone-in-symfony-1-1
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:
http://trac.ullright.org/browser/trunk/plugins/ullCorePlugin/config/ullCorePluginConfiguration.class.php

Symfony patch enabling fallback to html templates: (Patches sfView.class.php)
http://trac.ullright.org/browser/trunk/plugins/ullCorePlugin/patch/sfView.patch.txt

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/myActionSuccess.mobile.php

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

Here’s the original post: http://groups.google.com/group/symfony-users/browse_thread/thread/9da0a9fe3cf3ff77

Have a nice day!

Written by: | 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 »

Written by: | 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 »

Written by: | 13 Comments | Category: Best Practices

Thank You

Yesterday I returned back to Vienna from Symfony Day Cologne 2009. The conference was amazingly well organized and many people deserve credits for making it such a great experience.

Symfony Day Cologne 2009

© Nicolas Perriault

Thank you Andreas and Dennis for putting uncounted hours into planning the event, guiding us around the city, spending the night before fixing the wireless connection and for taking care of all the other small things that usually go by unnoticed. Thank you Isabelle for your Cologne crash course and for organizing our flights and the perfect accommodation. Thank you Nicolas for your many thoughtful advices, I really appreciate them. Thank you Xavier, Stefan, Jon and Sebastian for your refreshing company; I really enjoyed the lengthy walks around the city, even though my foot complained somewhat. Thank you all the attendees who gave me feedback about my work and my presentation. Thank you Interlution for letting us take part in your 10 year anniversary party. And thank you all the other people involved in making this event a success.

Events like this one are really important for the community. They put faces behind names, make friends, open up new opportunities and spread ideas. They are what open source truly is about.

As another result of the conference, this blog features a new page Talks where I included the slides of my presentation Best Practice Testing with Lime 2. And to those who annoyed me about Twitter – apparently some new account @webmozart has been created over there. Don’t know who it is, but don’t expect him to tweet too much.

Written by: | No Comments | Category: Community

Additional Resources