Tag Archives: PHP

Annotations with Symfony2

With Symfony2 much configuration can be added directly to actions with annotations. With Symfony1 there have been cache.yml, route.yml, security.yml and many more configuration files for a single controller. This has not changed with Symfony2. You still are able to configure your (bundle) controller with single files. However, there is a new way which offers more flexibility and adds the configuration right to the place where it is used: to the specific action as meta-info with some sort of annotations.

First, your route.yml has to be edited and your bundle has to be added.

# app/config/route.yml
your_bundle:
    resource "@YourBundle/Controller/YourController.php"
    type: annotation

This is needed in every setup, but as you see, you can specify the route type as annotation. This means, Symfony2 will parse the doc block on any action of your controller file, and import this to route.yml. But don’t worry, Symfony2 does this just once and stores the information on the cached route.yml file.

Now you have to add the routing information on each action which should be imported as route, as shown below. You can also insert params to your route. Additionally to the route you can add various other settings direct to the action as also shown below.

class YourController
{
  /**
   * @extra:Route("/action/{id}", name"route_name", requirements = {"id" = "\d+"})
   * @extra:Template("YourBundle:Controller:action", vars={"your"})
   * @extra:Secure(roles="ROLE_MEMBER")
   * @extra:Cache(expires="+7 days")
   */
  public function yourAction($id)
  {
    $your = 'code ' . does('something with', $id);
  }
}

There is much more to come and everything is still under development. So expect changes and additions to these existing annotations.

Update 24.05.11
Yesterday, Fabien Potencier announced a change in the Annotation System of Symfony2. There is a official blog post explaining the changes.

Automatic Anti-Pattern Corrections for PHP

During my computer science studies at the Vorarlberg University of Applied Sciences I wrote my bachelor thesis about “Automatic Anti-Pattern Corrections for PHP”. As a fan of the open source philosophy, I want to share my work with others. I invite everyone to contribute to the great lex-pass project and this approach to better PHP software. Please share your thought and ideas on this with me and others by leaving a comment or sending me a message. Continue reading Automatic Anti-Pattern Corrections for PHP

Symfony 2.0 Preview

Here we go. Fabien Potencier last week released the preview website for symfony 2.0 (symfony reloaded). Me, as a long time PHP and symfony user this preview shows a lot of new interesting stuff comming to web development with symfony. A Quick-Tour of Fabiens newest baby is also available and points out major changes to the framework. First thing to notice is the completly changed directory structure. Another major step is the use of >= PHP 5.3.2 which adds support for namespaces and gives a great performance boost. As release date for symfony 2.0 “late 2010” is scheduled.
[ad#Google Adsense 468×60 Singlepost Mystique]

Symfony Support in NetBeans 6.8 Announced

The NetBeans Team has announced to support not just PHP 5.3 which was released earlier last week but also Symfony in the next release (6.8)!

Because I am not very pleased with the PHP support within Eclipse PDT, I am currently using VIM for PHP, and specially, Symfony development.

Since Pierre told me recently that the PHP support for NetBeans is getting better and better, I am really looking forward to the next NetBeans release.

More information on Symfony integration in Netbeans

PHP 5.3 Released

Well not yet, but hopefully in a couple of hours and minutes. (Check php.net) Although there are some new cool features in it such as lambda functions, closures and PHAR support, there is this silly namespace thing. Namespaces are good in generally (remember, you had to prefix each class with your damn project-name to be on the save side) but separating the namespace parts with the *escape* character “\” (YES THE BACKSLASH!) – the worst ever to choose character – is a awful and total painful thing.

I was hoping until the latest second before the release that someone will fix this BUG and replace the namespace-separator with a better character (maybe “_”, “-“, “..” or “|” since “.” (concat), “::” (static) are already used for other issues).

Do not get me wrong, I appreciate the great work the PHP5.3 Team has done but this namespace thing takes some of the coolness away from that release. Sad but true story.

*UPDATE* PHP 5.3.0 has been release now.

#php.de@IRCnet

Weil ich mich nie an die Blogs der unterschiedlichen Leute im IRCnet Channel #php.de erinnern kann, habe ich angefangen eine Liste mit eben den Blogs dieser anzulegen. Es gibt für jeden #php.de User die Möglichkeit sich selbst einzutragen, ich muss dann den entsprechenden Link lediglich noch freischalten.

Für alle Interessierten: #php.de@IRCnet Blogs

PHP-Code-Camp in München

Vom 3. bis zum 6. März 2008 findet in München das PHP Code Camp statt und es sind noch Plätze frei. Auf diesem Camp werden unterschiedliche Schulungen mit einigen bekannten Referenten abgehalten. Das Camp findet im NH Hotel Deutscher Kaiser direkt am Münchner Hauptbahnhof statt und kostet ab 1.790 Euro. Organisiert wird das Code Camp vom PHP Magazin und von der Entwickler Akademie und wird als ein neuartiges Trainingskonzept beworben, das vier Tage lang in konzentrierter Form vermittelt, wie PHP-Anwendungen mit professionellem Anspruch entwickelt werden können.

Ein Auszug aus dem geplanten Programm:

Interaktives Code-Review einer “schlechten” Anwendung
PHP-Security (SQL-Injection, XSS, Session-Hijacking, Input-Verarbeitung)
Objektorientierte Programmierung
Testgetriebene Entwicklung
Einführung in Unit Testing, Entwicklung von Unit Tests
Werkzeuge für die PHP-Entwicklung
Funktionale Tests
Patterns für PHP
Code-Review von schlechtem und gutem Code

Mehr Informationen:
PHP Code Camp