Nearly two years ago back in November 2008 I wrote about the
state of annotations in the PHP world. Today I want to take the chance to revisit this and find out if annotations are still present and used, or if they are not.
Review of old candidates
Of those which I described two years ago, AttributeReader saw no further development, so I don't consider it as an option any more.
Addendum has seen new releases, the last one in October last year. The repository has seen commits recently in June this year, so I believe it's not dead, but as it is feature complete there's of course not much development activity required any more.
The third candidate was FLOW3. FLOW3 is still alive and kickin', nearing it`s final stable 1.0.0 release. Annotations are still part of the framework and the
Introduction tutorial has usage examples of where you utilize annotations provided by the framework, for dependency injection and validation. The
manual additionally lists persistence and even
Aspect-Oriented Programming as usage scenarios. So as FLOW3 is likely to be adopted within the TYPO3 community we will see more and more FLOW3 based applications using annotations.
Another framework is Stubbles. From what was stated in the first blog post nothing has changed, beside the fact that Stubbles is now available in version 1.2.0, with versions 1.3.0 and 1.4.0 shipping within the next two or three weeks. Stubbles is used in various applications at
1&1 Internet where we make heavy usage of the annotation features.
The third framework mentioned was the
XP framework. Current release is 5.7.11 with 5.8.0 right around the corner. For the annotation part nothing has changed, and XP framework is used to build the intranet of
1&1 Internet as well as a lot of internal tools.
New kids on the block
So, the three frameworks providing annotations are still alive. Question is, are there any new kids on the block? A little research reveals: yes, there are.
One of them is
Pia which provides annotations and an annotation API for PHP 5.3. It seems to be under active development and there seems to be no release yet.
Nothing really usable yet, but recently a
feature idea for annotation support within the
Yii framework was brought up in their forums.
Another one is the
Recess! PHP Framework. Recess! uses annotations for routing and ORM. I did not find anything whether Recess! allows user-defined annotations or not.
Then there is
Symfony 2, currently scheduled for release in March 2011. Symfony integrates Doctrine 2 which uses annotations heavily to provide ORM features. It includes the Doctrine common annotations library which allows to
define and access your own annotations. The inclusion of Doctrine 2 into Symfony 2 makes me very confident we will see a major usage boost of annotations in the PHP community.
Conclusion
In the first edition of this article I already speculated about the idea of having support for annotations within the language itself. Now there is an
RFC for annotations including a patch which is discussed heavily on the PHP internals mailing list. Personally I would like to see this included in the PHP language, but it might be a long way ahead. It needs to fit into the language itself, and provide a syntax which integrates with the other parts of the language (though it might be noted that PHP is not very compliant in itself, but there's no need for history repeating).
However,
stating that there are no uses cases for annotations in PHP is simply not true. There won't be so much ideas about annotation support if it would be useless. As more and more implementations emerge, even ones which will boost the usage within the PHP community, I'm more than confident that annotations will become widely used in PHP. Providing support in the language would be a good way to give this a solid foundation.