Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML and YML in context of Symfony2 and SpringMVC

Tags:

spring

symfony

I'm on my way of getting a decent programmer but it seems that the things there are to learn are countless. I know that there's never a certain answer when one ask which is better, but I'll try to make my question more specific hoping for a more certain answer.

I'm using/working with PHP for a year now. Starting from the most simple examples, now I'm using CodeIgniter and various libraries/frameworks for the frontend and I feel like I need to make a step ahead, which in my case is learning another PHP framework - Symfony2 and also, because I'm getting my masters degree on "Software technologies" now and there I intensively use Java, I want to try and start learning both - Symfony2 and Spring. Among the many questions how to accomplish that without ending with just a lost time, the usage of XML, YML is something where I see an option for getting an edge in my work.

Java is heavily XML, and as far as I know, there's no escaping from XML in Java. But in Symfony2 one have a choice and it's very tempting to use XML there so I won't need to learn one more thing among all others but most of the examples I see for Symfony2 use YML and I'm not very sure that skipping yml and trying to stick strictly to XML won't turns back on me.

I'm not experienced neither in Spring or Symfony so if it was you learning both of them at a time how would you approach? Using XML for both, or using YML for Symfony2?

like image 386
Leron_says_get_back_Monica Avatar asked Nov 29 '25 16:11

Leron_says_get_back_Monica


1 Answers

I'm making my money as a Symfony developer, while developing my personal project in Spring MVC, so, since I've seen the both worlds, I think I have something to share on this topic.

I'm developing in PHP for like 7 years, and I know Java as a language for like 5 years, but I'm developing my first “real” Java project just for a month or two. Eventually, I want to ditch PHP for good and switch to Java and/or other JVM languages like Scala.

What's the reasoning for this? Well, don't get me wrong, Symfony2 is a great framework and I really love it. I believe it's the best PHP framework out there. But... it's still PHP, you know. No matter how great a PHP framework is, I just can't stand PHP as a language for too long. What's so wrong with PHP, you ask? There is a great article explaining exactly what I've been feeling about it for a long time (at least read the analogy section).

And since I prefer static binding and strong typing, I'm more comfortable with Java for this reason too. It's just so great what a Java IDE does compared to what the best PHP IDE does. I think I'm using the best IDEs for these languages out there — IDEA (with the PHP plugin) or PhpStorm — and Java support is just so much better it makes me want to dance.

I'm not saying that Java is the greatest language of all, but it's a huge improvement over PHP. I think Scala is very promising, but since its infrastucture/ecosystem is not mature enough for me — a pragmatic who likes to get the end-user projects done, compared to guys hacking the languages themselves and developing frameworks — I'm staying with Java for now.

So, for me it boils down to the language, community and ecosystem. While the PHP community has some great developers and I enjoy having conversations with them on IRC or other places, the Java community has much, much more great developers developing much, much more great stuff for the much, much bigger Java ecosystem.

Apart from those 3 things, I could add that Symfony is much easier to learn — its book and cookbook are great and really to the point, while I have to hunt down a lot of information about Spring in numerous books, blogs and its vast documentation.

Speaking of YML and XML, you can do a Symfony project in XML only, and you can do a Spring project completely or almost completely without XML — especially since version 3.1. I use YML in my Symfony projects but XML for bundles I share.

And since Symfony DIC and security are based on Spring and Spring Security, and Doctrine is based on JPA, learning idioms of one of these frameworks, you learn a lot about the other one. What I'm really missing is a Twig analog in the Spring MVC world — JSP gets the job done, but it's not that great. I know there are other view technologies Spring MVC integrates with, but to me it seems like JSP is the most endorsed one.

like image 54
Elnur Abdurrakhimov Avatar answered Dec 02 '25 06:12

Elnur Abdurrakhimov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!