FOSUserBundle: what is the point? [closed]
Asked Answered
B

2

7

I've seen many people trying to use FOSUserBundle.

I've been struggling with it for 6 hours now. Just to be able to make a custom user registration form. The basic documentation is 6 pages long: basic. Here are all the drawbacks of using FOSUserBundle, from my point of view:

  • you have to copy paste their views to make inheritance possible
  • they have their own table on the database: fos_user. So you have to base all your code on your user entity, which a child of BaseUser. If your database follows a convention (like wordpress does, with all tables beginning with wp_) this breaks your convention.
  • you have to hack all you own views with things like "if the fos_user_content block is empty i suppose there's nothing to display, otherwise i have to re-organize my whole view to display the fos_user_content block (registration, modify user profile and so on)"
  • and now I see that if you need two different registration forms (for example, one for client, one for partners) it's not possible unless you hack. See here.

So I'm just wondering: what is the point of using if FOSUserBundle? If I've already done a registration process that follows the very basic things explained in Symfony help (forms, form validation, and sessions) and I just copy paste my code, this is, from my point of view, far faster than installing, configuring, inheriting, modifying and so on the FOSUserBundle.

Knowing what I've done, what are the advantages of FOSUserBundle? What could make me change and take some more hours to make it work with my project, instead of re-using my (forms, form validation, and sessions) from another project?

Bottleneck answered 28/9, 2013 at 7:53 Comment(7)
Process of implementation of all features you need is supposed to be faster with FOSUserBundle. If you can do it faster and better another way, don't use it.Photobathic
I've been banging my head against a wall to make it work with PUGXMultiUserBundle because this one is supposed to help me having multiple users. I've managed to setup everything and now, OMG, after having managed to display two different registration forms, when I post with one or with another one, I get a totally incomprehensible error: from what I can understand, doctrine tries to make a join without the table "t0":Bottleneck
(following) An exception occurred while executing 'SELECT t1.username AS username2, t1.username_canonical AS username_canonical3, t1.email AS email4, t1.email_canonical AS email_canonical5, t1.enabled AS enabled6, t1.salt AS salt7, t1.password AS password8,[...snap...] FROM person_teacher t1 WHERE t0.username_canonical = ?' with params ["[email protected]"]: SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.username_canonical' in 'where clause'.Bottleneck
... and of course, absolutely ZERO clue or help on the web with this kind of error. I'm beginning to be fed up with symfony. I spend almost all my time trying to solve configuration problems, not technical or anything else.Bottleneck
I implemented different types of users with FOSUserBundle but without using PUGXMultiUserBundle.. so I didn't have this error..Photobathic
Perhaps it wasn't the cas before but now you can specify the table/document name with the user class annotations.Unexperienced
FOSUserBundle is hard to use, It is not Devise in Ruby On RailsPluton
E
5

Well, your question sounds more like a rant, but you got some points.

In my opinion, the main problem of the FOSUserBundle as well as a lot of Bundle in the community, is that they try to make it customizable, generic, re-usable, whatever.

The goal is fair, but in reality it often leads to not human friendly code. Most of the time, you will take much more time to "get it done" using community bundle than making your own (see Sonata bundles).

I don't say they are bad bundles, not at all, but they deserve different purposes.

For me such bundles may help newcomers to have a quick implementation, to get things done, and in the case of a Rapid Application Development, it may be really easy to get a fully working application with all the registration process done.

But most of the time, you realize that using third party codes ties you too much to their own concept and that is wrong.

In comparison, I do like very much the npm community, there are A LOT of little package with one function which you can easily integrate, in the same way, I try, to favor library instead of bundle when I want to release an open source project. The point is the framework implementation is free of any concept or philosophy and easily integrate in an existing project.

I remember some early days where I had to play with Joomla, Drupal, Wordpress, whatever, it was the "plugin/extension/module" fashion, in the same way that we often hear "there is a bundle for that", some people, or company just want to get it done, no matter the quality, the future of the application because it already have been sold.

To conclude, such bundles can greatly help and speed up development process, but be careful, if you have custom requirements, performance implication, etc. don't use them, however if you only want to a quick proof of concept, or a simple application, it is worth.

This is a fiction story based on my own experience and failures using it :)

Exonerate answered 3/2, 2014 at 10:47 Comment(8)
I do agree with you: if you dont want to use the bundle exactly the way it has been made for, it will take more time to modify it than to develop your own. FYI, I've lost lot of money because of Symfony and what it claims to be very useful. I would have gain money if I had done it from scratch. But I've lost days & days searching how to use this bundle, how to hack this one, and the worst of all: how to use doctrine, which I'll always explain why avoid it each time one of my student will ask what it is.Bottleneck
+1 Really nice summary of bundles, plugins in general, i often find that its easier in the long run to write my own stuff, rather than having to hack my way around something someone else has written, no matter how good its documentation/code is. Bundles can get you started on a project quickly and saves a lot of time, for new users especially, I feel for new people, it prevents them from learning, as they dont really get to understand "How it works"Towle
"how to use doctrine, which I'll always explain why avoid it each time one of my student will ask what it is"... sounds really backed up with facts and arguments. Obviously not... Anyway, you don't need to hack them to use them properly, it is just a matter of a steep learning curve (+ matching use case and how widely it is used in the community) if you don't have the proper knowledge. Imo you are right on this point: you don't like it ? then don't use it. But to say such BS to students it is plain wrong.Bellina
@Bellina It is not BS, especially if they are students. If they start with something like doctrine2 will they ever know how simple it is to just write an SQL statement with PDO? Or will they think that they need such a complex thing as doctrine2 (and use DQL which will only work for doctrine2)? Most websites only need a router and a template system. If you know about design patterns you can structure something to deal with your database (DataMapper, Repository) for forms you can create some utility classes.Rodrickrodrigez
Don't get me wrong, I totally agree with Boris Guéry answer, everything he wrote. But Olivier Pons comment just doesn't sound right at all. First if he lost money it's not because of Symfony but obviously how he used it. Money making has to do with how you sell your time / craft / products. Doctrine is not so hard to use if you have the proper background. It is inspired from Hibernate in the Java world, it's a widely used pattern called ORM. Now if you want to argue it's bad, it's ok but please bring some arguments: yegor256.com/2014/12/01/orm-offensive-anti-pattern.html.Bellina
I think ORM is an important concept for students to learn, because it is widely used in IT companies. "Most websites only need a router and a template system" ? > obviously it depends where you are working. Nonetheless I agree with you AntonioCS one should learn SQL first.Bellina
@Bellina Some years later here's my answer: Symfony is definitely not for big systems (I've had many demands of big companies because they had incredibly turnovers: people came then quickly left on all Symfony projects), and not for small ones. So for nothing. I've left Symfony in favor of Python+Django and I've earned almost exaclty 3x times my salary each month since then. I'm happier than ever, and I can tell I'm between 2 and 10 times faster when it comes to building websites with Python/Django than with Symfony (I'm taking bets and I've always won in 5 years ;^)).Bottleneck
@Bellina And for your information I wrote 15 years ago a full framework in Php with Smarty and my own ORM where more than 50 people have worked on. I rewrote it from scratch 3 times. So I not a beginner with Php and even less a beginner with ORM. But I can wrote in two lines in ORM Django / Python what takes 30 lines in Symfony (with models declaration in comments! This might seem normal when you get used to that, but hey! Take a break and look far from the code: seriously, you have to define how your ORM behaves through code comments? Django is clean beautiful an do use real code!)Bottleneck
B
1

I know this is an old post but as search engines keep indexing this...

FYI FOSUserBundle has been discontinued and is of no use in Symfony 4 and 5...

Sources

  1. No Longer Maintained Message On Documentation #2874
  2. Is this project maintained? #2996
  3. Comment with alternatives by Caedendi on 10 Jan 2020
Basel answered 25/2, 2021 at 13:37 Comment(1)
I like the comment in your first link: "this bundle is not really necessary (it tries to be a all-in-one solution for user management in Symfony, but it's not very good at it when you can write it yourself easily)". For your information, I've given up on Php 5 years ago, partly because of Symfony, and I've become a Django expert and my life is better on all sides since then: much better salary, much cleaner code (thanks Python), very friendly team collaboration, well: all in all, only time lost with Symfony, 0/20 benefits. Not even 1/20.Bottleneck

© 2022 - 2024 — McMap. All rights reserved.