Settings

Theme

What is Symfony2?

fabien.potencier.org

92 points by jmikola 14 years ago · 25 comments

Reader

lkrubner 14 years ago

I worked with Symfony for almost 3 years, from 2008 to 2010. This year I'm working on a big Ruby on Rails project. And before 2008, most of the work I did involved hacked together PHP projects. I would say that if one can use Ruby On Rails, then of course one should. It doesn't matter whether Ruby is better than PHP as a language, what is certain is that Ruby ecosystem is much stronger than anything in the world of PHP, and for any large project you will be depending on whatever ecosystem surrounds a language.

Having said that, I would say that Symfony is the best hope for PHP. It is the framework that takes PHP furthest forward, and offers the best starting point of a strong ecosystem. Symfony imitates many of the best features of Rails.

I've worked on a lot of PHP projects. I've worked on WordPress and Drupal and CakePHP. I dislike nearly all software written in PHP. But Symfony is elegant and clean and the people behind it are serious and intelligent. If you have to work with PHP, then you should work with Symfony.

However, I do not expect the Symfony community to ever grow large, and I will quote something that I wrote on my blog a year ago to explain why:

"No matter what data source you consult, the conclusion is unmistakable: Symfony is a small community, and its rate of growth is slow. Why is this? My own theory is that Symfony brings to PHP something that PHP has long been missing: a truly professional, industrial strength, object oriented architecture that allows PHP to be taken seriously in the enterprise. However, all of the people who would be truly interested in such a framework have long ago found a home using Ruby, Java or Python. In short, the kinds of people who gravitate to PHP are exactly the kind of people who are unwilling or unable to appreciate the beautiful elegance and power of a system like Symfony. The people who need something like Symfony gravitate to other languages."

http://www.teamlalala.com/blog/2010/04/11/the-symfony-commun...

  • mgkimsal 14 years ago

    This still conflates language with platform/framework. There's a reason PHP is big and Symfony is small - only a fraction of the PHP users have needs that are met by symfony and have the time/effort to learn symfony in the first place.

    There's actually probably multiple reasons, but that's the easiest one off the top of my head. PHP's used in all kinds of web places that Ruby isn't, mostly because Ruby's not a great fit in those places.

    Hello <?=$name;?> it's <?=date("h:i:s");?>.

    I've never met anyone who does 'ruby pages' and drops ruby in to various files as needed for small stuff. You can do that and many people do with PHP.

    All web work I've ever seen done in Ruby uses Rails or Sinatra or some framework. Only a portion of web work I've seen in PHP uses any community framework. This is just the way it is.

    Your point on ecosystems is correct - the ZF system is probably the closest modern one out there (indeed, ZF should have been called PEAR2 years ago) - Symfony uses bits of ZF libraries as needed. But because of the naming, people think you use all of it. Because Rails was/is the dominant web framework in Ruby for so long, it feeds on itself, and people end up writing cool stuff for Rails, and more people use it because of the cool stuff, lather rinse repeat. The cool symfony stuff mostly can't be used outside symfony, CI stuff not usable outside CI, etc.

    There's some cool stuff in Grails I use - it's not possible in PHP (maybe in the future if the language changes) so I use Grails when need be (or when I feel like it). No amount of libraries/frameworks in PHP will make up for the missing language features, and this is the heart of your last paragraph (which I agree with). I still use PHP for a lot of stuff, but have expanded out to other tools that fit other use cases better.

    I do wish I'd see other camps being as broadminded as they exhort PHP users to be, though. By and large, there's stil loads of people that try to do all their projects in Rails, or J2EE, or .NET, or Django, or whatever. PHP's got its place, and sometimes really is the best choice for a project. Ultimately, there's still loads of fanboys out there in all camps. :/

    • eropple 14 years ago

      > Only a portion of web work I've seen in PHP uses any community framework. This is just the way it is.

      This is not a good thing! It's one of the biggest reasons why the overall state of PHP development, @fabpot and friends excluded, is absolutely terrible.

      • jasonlotito 14 years ago

        > It's one of the biggest reasons why ...

        One person having limited experience with professional PHP development doesn't make it the overall state of PHP development.

        The majority of PHP development I've see use these community frameworks like Zend and Symfony. They also use a lot of other well established tools. Things like CodeCoverage and PHPUnit, xdebug, and countless other solid, well written tools.

        I'm sorry, but when people refer to PHP development and relate to WordPress or Drupal, I can't help but shake my head. If that's your idea of professional level PHP, I'd hate to see what you think professional level code in your language looks like.

        The overall state of PHP development is doing well. We have a lot of professionals writing solid code. Yes, we have a lot of people that flock to WordPress and Drupal, or pick up CI and think they are following best practices in PHP. Many move off to a framework in another language, thankful to get away from PHP and the horrible code it forced them to write.

        • eropple 14 years ago

          For quite a long time I was a PHP guy. I've used pretty much any PHP framework you'd care to name. I rolled my own unit test framework before PHPUnit even existed. I was using DBG when xdebug was launched. I was patching PHP to use FPM long before it was in core. Believe you me, I am entirely too familiar with PHP and the ecosystem around it and I wouldn't go back in part because tools like xdebug really are that bad in comparison to what you get with something like Scala or .NET.

          The problem is less the language, which is slippery and broken in interesting and different ways from version to version but generally not in ways that are real killers. The real problem is that those people that you say aren't professional developers (and they're not!) and are considered important use cases. This is a language where the core developers actually care about people who splat HTML in their PHP and vice versa. They're the people who don't even know about mysql_real_escape_string (LOL), let alone PDO or doctrine-dbal. And if those guys are just hanging on, great, more power to them, but the core PHP team actually cares about the use case for these people, while for the most part, they really don't seem to care about the use case for people who want to Do It Right. The distaste from guys like Rasmus toward the various framework projects is well-known and I kinda think it has an impact on the language itself.

          This is I've seen as commonplace PHP development:

          -Misuse of Mediawiki as a corporate intranet, using and extending scary plugins like template parser functions.

          -Autogenerated CakePHP monstrosities that barely function and doesn't if you have to make significant changes.

          -Home-rolled extensions to Drupal for that one little thing that SomeCo's website really just had to have. Ditto Wordpress, ditto Joomla.

          Don't get me wrong: it is entirely possible to write good PHP. I'd say, with a decent bit of conviction, that the possibility of doing so goes down sublinearly with the amount of code/feature-points/other-measure-of-size and goes down superlinearly with the number of other people touching your code. But it's totally possible to do so. I wouldn't have used it for most of a decade if it wasn't. But I am entirely and completely convinced it is the sad minority, with the crazy majority largely catered to by the PHP development team, and it's a major reason why I've gone on to saner pastures.

          • jasonlotito 14 years ago

            You see, when you mention those things (Mediawiki, CakePHP monstrosities, Drupal/WordPress/Joomla), I don't equate that to professional development at all. And no, I've never run across that.

            Maybe this is why my view is the way it is. I've never had to deal with the above. And I honestly don't see how a professional could work in that environment (I mean, honestly, how does someone choose to work with Joomla, and then have the gall to complain about it).

            The majority of people I deal with (the very large majority) are professionals in their craft. This means they aren't just PHP developers, but when they write PHP, it's professional level code. It's what you'd find being written for any other language.

            I find it odd that every time someone rags on PHP, it's generally always involves WordPress, or Drupal, or Joomla, or something akin to that. And when I read that, I understand why someone might feel that way. But then Drupal and WordPress or Joomla aren't fair examples of anything I've written in PHP. In fact, a part of me has the hutzpah to think that if you decided to use them as your tools to do something, it's your own damn fault.

            So yeah. Maybe their is a large population I'm not involved with, that I know nothing about. I can't say your examples strike a chord with me. I don't have a hate for developing with Joomla because I never wanted to go there. And what little work I've done with WordPress was painful because of the architecture of WordPress, not PHP.

            I'm just tired of very HN post on PHP has to result in retards (not necessarily you are mgkismal) coming out to post childish comments, or how everyone has to pepper their comments with weak shit like "Oh, I'm such a great programmer, and if I had to use PHP -- not that I have to, thank GOD for THAT! -- I'd polish that turd, LOL!"

            It gets tiring. And it's insulting. Not because they are insulting a language I use. Rather, it's insulting because the community here encourages it. It's accepted. And I like to HN is filled with smart people who will judge me based on the results of my work and not the fact that fact that I didn't use a Craftsman hammer, but instead a plain wooden one that goes the job done equally well.

            Sorry for the rant.

        • mgkimsal 14 years ago

          Wow - I'm taking a bit of personal affront to this. I'm not 'one person with limited experience with professional PHP development'. I've been PHPing since 1996 (from PHP/FI), and have done work with both PHP and many other platforms. I was doing MVC in PHP4 well before most of the popular frameworks of today were even started (probably before many of their authors were using PHP).

          Read this again:

          "Only a portion of web work I've seen in PHP uses any community framework."

          I see a hell of a lot more PHP than I actually work on myself. I've run multiple PHP groups over the last decade, and have consulted with well dozens of companies of all sizes during that time frame.

          What the hell - take me out of it. Look around at most PHP code out there (go look at github or sf). It's not based on Symfony, ZF, Cake, CI or whatever your favorite framework and tools may be. That's just how it is. I didn't say it was good, but it's the state of things. No one said this was good or bad (you say it's bad, I tend to agree, but not 100%).

          Yeah, perhaps I shouldn't have taken that as personally as you meant it, but I expected a bit more from you Jason. Maybe you meant that comment more at the OP - not sure.

          • jasonlotito 14 years ago

            tl;dr, Honest apology, and honest rant around people who litter HN with stupid posts.

            I was a bit harsher than I should have been, but I also see quite a bit, and it's encouraging. Sure, if you look around github and SF, you see a lot of libs/class that aren't built for Zend or Symfony, but then they shouldn't be built around a specific framework. Heck, even Zend/Symf attempts to make each component indecent and replaceable.

            And while you have big names like Drupal and Wordpress, people constantly prop those up as if somehow they are prime examples of professional level PHP code. It would be like me saying Ruby can't run on busy websites and use Twitter as an example. It's just old news.

            And regardless of when you started PHP, it's fairly clear you haven't been as involved with the community over the past few years (or if you have, nothing in your comment gives that impression). Otherwise, you'd know about all the projects that are being launched/have been launched on top of frameworks. Open source projects, community projects using Zend, Symonfy, CI, etc.

            The professional PHP community isn't made up of some rag tag group of people who don't know better. It's made up of incredibly smart people who write excellent code. I'm sorry, but nothing in Python or Ruby or any other language makes you a better programmer. They are excellent languages, but I've yet to meet a language that can fix stupid (though, some support it better than others).

            I'm sorry if I offended you. But, I enjoy PHP. It's an amazingly flexible language. Yes, it has warts, but it gets frustrating every time the topic comes up on HN, people rag on it like somehow it's the worst thing since sliced bread. It gets tiresome. Worse than that, it gets insulting.

            And for what? What's the point? What's the fucking point? I could easily point to Diaspora's initial launch and say "Yeah, awesome! That's what all that money buys you for an awesome open source Ruby project." But I don't. Because it's stupid. Its childish. Its pointless.

            So yeah. I get it. PHP is the red headed step child that everyone likes to beat on. And that I like it makes me an immature stupid twit that doesn't know the first thing about programming. My respect for fellow professionals be damned, as they don't have a clue either. And by choosing PHP as my choice for a web language is based on clear brain damage at the hands of too many cold winters up north.

            So yeah, this is me venting. And I don't mean to do it all over you. But it gets tiresome that every time there is a post about PHP, it has to consist of people bad mouthing anyone who chooses to use PHP, let alone the topic at hand.

            Sorry for going apeshit all over this, and sorry for ragging on you. Your commentary is generally well appreciated. It's just getting tiresome, and I guess a part of me responds to all the comments in one.

            • mgkimsal 14 years ago

              OK - I get your point. I guess I'm still a bit confused about this:

              ..."it's fairly clear you haven't been as involved with the community over the past few years (or if you have, nothing in your comment gives that impression). Otherwise, you'd know about all the projects that are being launched/have been launched on top of frameworks. Open source projects, community projects using Zend, Symonfy, CI, etc.

              What in my comment should give that impression? Maybe I still don't get it. Yes, there are projects being built on top of frameworks. (I started zfkit some time ago, although other people have done much more in that area than I have). I've done project work using various frameworks.

              I'm not ragging on PHP at all, and don't really know where you got that from. To the extent I'm seemingly ragging on Symfony, it's only that it's complicated and doesn't speak to everyone's needs. Many people still really just need a <?=$name;?> type language to suit their small needs, and PHP works great for that (as well as works great for many larger scale projects as well).

              Honestly, really, I hope you were reacting to someone else and I just got caught up in this as a misdirected target. I teach PHP for Zend, have certification, just got back from Zendcon, and use PHP for about 70% of my work (using various frameworks). I enjoy PHP too - again, not sure where you're getting some idea that I don't enjoy it.

              Oh... yeah, I said that the language can't do some things I can do in Groovy (or Ruby). Yeah, things I enjoy and like. You know something, learning other languages has made me a better developer, both in PHP and in those other languages, because I can appreciate idiomatic PHP as much as idiomatic $lang. PHP's taken some cues from other languages and implemented neat things, some of which make things easier. I still don't like the syntax of things, and we don't have the same sort of metaprogramming facilities I enjoy in Groovy. But I'm not complaining - I love them both equally.

              What does annoy me is that people can't put out a "negative" view of PHP without raising the sort of rant you just posted here. Just because someone points out that PHP is missing something, it's not an automatic assault on everyone who uses PHP, nor is it stating that everyone who uses PHP is somehow an incompetent idiot. I'm pretty damn impressed with some of the stuff I see from people in the PHP community after all these years. I do wish some of them would at least acknowledge that other languages/platforms have some cool stuff in them too. That's happening, but far more slowly than I'd like to see. Even at Zendcon, there was a bit of an "us vs them" mentality I picked up in the hallway comments, and that saddens me.

              At a CF conference a couple years ago someone brought up PHP and made some joke about people needing training wheels. WTF - this from a language that didn't allow user defined functions for the first X years? And somehow you think PHP is a 'toy'? Every platform/lang has pros and cons, and the factionalization and party politics are really starting to get me down - it's actually part of the reason I don't get in to various frameworks too much (I marginally use ZF as a default unless there's some reason not to). Even inside PHP, the framework zealots like to bash each other's frameworks (Cake vs ZF vs Symfony, etc) - they all suck and are all great - just use something and get your job done.

              re: Diaspora - I'd say a year ago, public criticism might have had a chance of changing direction to get something more valuable out of it. Today, yeah, public criticism is pointless, as it is for more frameworks - you either like it or you don't, and move on.

              So.. yeah, this was a big rant reply. You triggered a lot of thoughts, but overall, I think we're in agreement about a lot of things. People often dismiss PHP as a toy still - but PHP people do it to others as well (listen to PHP people dismiss Perl, Java, etc).

              • jasonlotito 14 years ago

                I don't remember what it was specifically about your post that set me off, and rereading it, you didn't deserve the treatment. I'm sorry. As I mentioned, it's reading different comments, then coming to yours, something lights the spark, and I went into flamewar mode. Not fair to you (or anyone, really).

                > What does annoy me is that people can't put out a "negative" view of PHP without raising the sort of rant you just posted here.

                It's not comments negative to PHP. It's comments negative to people who use PHP. All too often I read people quip about "If I'd be forced to use PHP for my projects — which, luckily, I'm currently not" or they get all scotsmans and say things like "No real programmer would choose to use PHP these days...". And this seems to have every. Maybe it's bias. I've grown so accustomed to it that I look for it, and start seeing it where it doesn't occur.

                And I completely realize I'm not helping matters any.

                I love learning new languages, learning their quirks. And I can't fathom how an intelligent person can casually insult people simply for their tool choice.

                Thank you for being as gracious as you have been. I've been nothing but a dick.

                • mgkimsal 14 years ago

                  Wow - thank you for being so straightforward and gracious yourself. I probably went overboard in my replies, but it was good to hash some of this out.

                  FWIW, I agree on the type of statements you're referring too - they bug the hell out of me.

                  I'm OK, you're OK (and PHP's OK too!) :)

  • jasonlotito 14 years ago

    > I've worked on a lot of PHP projects. I've worked on WordPress and Drupal and CakePHP.

    Well, that's your problem right there. Don't blame C for Windows XP.

  • jordanlev 14 years ago

    I totally agree with you about the difference between the Ruby and PHP communities. But I think when you say "the best hope for PHP...", you might be forgetting that not every project using PHP is a big application. I think Rails would be overkill for a smaller project (for example, an informational website for a small business), and so would Symfony (which the author of the linked article says himself). I bet a majority of the usage of PHP out there is for much smaller tasks that might benefit a little bit from a framework (or at least a separation of concerns), but would not be worth switching to a different language and platform (not to mention the deployment piece of the puzzle).

stdbrouw 14 years ago

To all those who have ever taken a look at Symfony: v1 was ugly but v2 is much more palatable to people with experience in Python/Ruby/Node, and the docs are pretty darn good, so have another look.

If I'd be forced to use PHP for my projects — which, luckily, I'm currently not — I'd pick Symfony2 over Yii, CodeIgniter and CakePHP any day.

  • w33ble 14 years ago

    I'm curious; what is it about Symfony2 that makes you recommend it over CakePHP?

    I really enjoy using CakePHP personally, and I found Symfony v1 a headache to start with and never really got off the ground with it. It's interesting to me that the CakePHP 2.0 release got no love while Symfony2 is front page material. Any insight here would be appreciated.

    • eropple 14 years ago

      Quickly:

      -CakePHP is atrociously slow, even when running with APC, and uses an alarming amount of memory for what you get. Symfony2 is neither slow nor particularly memory-hungry.

      -CakePHP is inexpressive; it's very difficult to use it piecemeal. You either use the whole whomp of it or you don't use it at all. Symfony2 is modular and easily used for exactly what you need.

      -CakePHP is stuck in the past; any framework that is intentionally made compatible with versions earlier than PHP 5.3 is short-changing its users by not taking advantage of exactly what the language is capable of doing.

      It has no real redeeming features. (Note that I wouldn't recommend PHP in any greenfield development today, but if you have to do it, Symfony2, or at least the Silex core, are no-brainers.)

      • Arcanum-XIII 14 years ago

        "Note that I wouldn't recommend PHP in any greenfield development today"

        I'm curious, but what would you recommend ? I'm not cynic — but I work in a very small startup, doing mainly maintenance code in php and I've suffered my share of "use Drupal for x" when x is inappropriate inside Drupal, or any cms, and would have asked for a mostly custom backend designed from the ground up. So for these case I'm stuck — trying to do my best within the constrain I have. But for the occasion where I can do better, I'm curious about alternative !

        • eropple 14 years ago

          I generally use Java and Scala for my own personal projects. Scala less than I'd like because there's no really good solution for web development aside from Lift (and Lift, while comprised of fantastic code, doesn't map well to my mental model of web development), but moving more and more towards it over time.

          Some Python too, but that's more for one-offs.

    • Aidan 14 years ago

      I used CakePHP exclusively for many years, wrote several popular articles and contributed several components. I stopped baking primarily because I grew tired and frustrated with the community more than anything else.

      CakePHP is the only open source project I was involved with where the core developers mailing list was private, new major versions were developed in private repos, and inline documentation was banned (because "inline code comments often go out of date").

      It's a critical realisation that often the health of a community is more important than the product itself.

julesm 14 years ago

I have a few years experience with CakePHP, Symfony 1 and I have also been playing around with Ruby on Rails a bit.

Now, I just finished going through the Symfony 2 internals to see what is so different from Symfony 1. I have to say that, when I realized the paradigm change, I had a WOW moment.

I mean most of the frameworks gravitate around the classical "MVC monilith active record framework" and they all resemble more or less Rails.

Symfony 2 isn't even a MVC framework (although it separates concerns very well), I mean it doesn't even have a Model!!!

At the core it's a Kernel object that is responsible for building a Service Container for dependency injection, into which all sorts of Components get pluged-in as services. And along the way it triggers lots of events to which you can attach listeners.

That's it! Everything else you augment by choosing the kind component you want to use and by configuring the Service Container.

After the little bit I played around with Ruby on Rails I have to say that Ruby is much nicer then PHP, but as a framework I really like where Symfony 2 was taken.

pxtreme75 14 years ago

PHP can be very handy for simple tasks -- and that make it very popular among starter programmers and unpopular as an enterprise, serious programming language for many experienced programmers. From my point-of-view, this is like you are trying to differentiate yourself through the tools you use and not your actual work.

The truth is that when you need to get things does PHP can be a much more convinient tool than ruby-on-rails. The following Blog describe this better than I would ever do: http://www.oreillynet.com/ruby/blog/2007/09/7_reasons_i_swit...

Regarding PHP frameworks: A year ago I decided to try most PHP frameworks. I recall working with ZendFramework, Symphony (not v2 to be honest), CakePHP and Yii. At the end of the day I preferred and used Yii simple because it made easier to start producing something useful.

lhnz 14 years ago

I've not used Symfony2 but my colleagues say that the admin functionality is not as good as what exists for Symfony1. Is this still the case?

cies 14 years ago

i just had a look at it.. one: i feel sad for all who are 'married' to php. :-P two: it seems that php is catching up on the frameworks (code ignitor, cake, yii, and this one)

  • jtreminio 14 years ago

    Thanks, but I don't need your pity. I enjoy working with PHP, and I really enjoy studying, playing around, and finally making money with quality frameworks like Kohana and Symfony2 (still learning this one).

    I may not be an uber-programmer like you, or have a $55,000 college education/loan, but PHP makes it easy, fun and profitable to be self taught.

    So, yes, I'm "married" to PHP, much like I'm married to jQuery, but keep your pity to yourself.

  • jamesgeck0 14 years ago

    I like the way Symfony2 is laid out. The project structure it gives you seems better suited to large applications than the way Rails lumps everything together.

    Unfortunately, in the beta, you had to place the bundle name/path in a about six different places for a single bundle. It was somewhat cumbersome to do manually (although there was a rails-like generator script).

    I also wasn't trilled with the debug messages. Half the time they gave information about the internals of the framework and no reference to the place in my bundle where the error was.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection