0

Is it just for separation of concerns?

Is there any other advantage? Do you know of any bundles that use annotations instead?

Another thing to note is that symfony-standard uses yaml by default; This is also true for the cookbook.

d0001
  • 2,162
  • 3
  • 20
  • 46

1 Answers1

3

This applies to symfony1 but probably nothing has changed. Source.

What's the best Format for your Service Definitions?

  • Using the XML format gives you several advantages over the YAML one: When a XML file is loaded, it is automatically validated with the built-in services.xsd file;

  • The XML can be auto-completed in IDEs;

  • The XML format is faster than the YAML one;

  • The XML format as no external dependencies (the YAML format relies on the sfYAML component).

Alexey B.
  • 11,965
  • 2
  • 49
  • 73
  • 1
    Additionally XML has top priority for service/routing/parameters etc. registration. – NHG Aug 30 '13 at 07:12
  • Thanks. Very good explanation if it still applies to Symfony2, which probably does. I still wonder how xml/yml compare to annotations and why very few bundles use it. I believe one reason is separation of concerns but I wonder if XML still has these advantages over Annotations. I once read that doctrine implements new features with annotations; if this is true there must be a reason. I wished I could find that reading. – d0001 Aug 30 '13 at 07:18
  • Annotations extracted from codes with very ugly method - file parsed or it comes from reflection. It is very slow method and annotations always need to be cached. You can see this cache files in app/cache/annotation folder. So it the most *slowest* way, bit most *readable*. imho, in prod environmemt cache always enabled and speed almost equvalent. – Alexey B. Aug 30 '13 at 07:48
  • @Daniel - Can you find and post the article about doctrine and new features? I'd be surprised if they actually did that. All of the mapping info, regardless of the source, ends up in a cached php file for the rest of the system to use. – Cerad Aug 30 '13 at 12:08
  • What I meant was that they implement new features with annotation support first then they add support for xml and yml. Like you said , at the end it ends up in a cached php. I will post it if I ever find it. – d0001 Sep 01 '13 at 04:37
  • Also, while I think this answer is very helpful I have not accepted it because we still don't know if this also applies to Symfony2. Another thing to note is that symfony-standard uses yaml by default; This is also true for the cookbook. – d0001 Sep 01 '13 at 05:43
  • All core symfony bundles(security, twig, framework, webprofiler) uses xml. Also [must populare](http://knpbundles.com/best) bundles uses xml. Anyway all features that you can get with annotations in doctrine you can get with other configuration formats. – Alexey B. Sep 01 '13 at 09:00