Symfony 2.0 – Notes

Some thoughts about Symfony 2. I didn’t play with the sandbox yet, I just read the doc and browse the code (a little bit). So more to come…

routing « inheritence »

One main routing file that can include to other routing files

# hello/config/routing.yml
homepage:
  pattern:  /
  defaults: { _bundle: WebBundle, _controller: Default, _action: index }

hello:
  resource: HelloBundle/Resources/config/routing.yml

Components are actions, yeah!!

Everything is an action, and you can include an action into a template. That’s great, no need to define an action that just include a component (when you need some ajax but the first load is not ajax)

Generating Links

The generate() method takes the route name and an array of values as arguments.

Mmm, I hope there is another way to generate a route, using the controller name and action name (like the old « url_for »…). I think it’s part of the « kill the magic » cleanup…

Assets and links to images, css, js…

<img src="<?php echo $view->assets->getUrl('images/logo.png') ?>" />

You will be able to change the URL root path of your web app without breaking any links. I love it, but HTML integrators will complain… But I like it… and they will (have to?) live with that.

« imports » directive in Configuration file: cleaner configuration files!

#in config_prod.yml
imports:
  - { resource: config.yml }

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *