New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event driven design #21
Comments
While I really really like Event Driven Design, I don't think it's good to add it to the best practices. For the same reason as adding DDD or the decouple-from-the-framework approach isn't a good fit for the best practices. Keep in mind that the best practices are for beginners, for people that are new to symfony and want to learn a quick way of using Symfony. With bad wording, it's like the RAD practices for Symfony. |
-1, yes I think it is a good practices but not for this demo app which is for new comers |
I'm divided in this. I agree with @wouterj and @94noni that this may be too much ... but I also agree with @sebastianblum and I'd like to see more useful examples related to the event dispatcher. Although this application is aimed at newcomers, I'd like to show at least one example of how to do "everything" with Symfony. |
DDD is clear that the separation of business logic and symfony should not be part of the best practices. in my opinion, event driven design is one of the best features in symfony and it is difficult to learn for beginners. If the beginners don't understand event driven design by seeing the code for the first time, the best practices shows the possibility. I would vote for integration event driven design and thin controller examples in the best practices demo code. wish you happy eastern. |
We can use branch to have a level beginner and mid level. |
@b-durand I'm afraid that maintaiing two different branches for beginners and experts is something we cannot consider at the moment. It would be to hard to maintain. |
+1. Why not make sure we have something like this in the docs? I don't see any reason why a cookbook couldn't have a link to a GitHub repo with the code that goes along with it (in fact, I think this is something we should think about doing in the docs). Then we can keep the demo simple, but have other example projects. |
As an example of an event driven design I would suggest to create simple LastLoginListener like this one in the FOSUserBundle: https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/EventListener/LastLoginListener.php. It would be simple and easy to understand for beginners. |
As the demo application should keep things simple for beginners and focuses on best practices, we thought eventually about creating a new "advanced demo application" (somehow installable through the Symfony installer as well). We'd like to start with advanced form usages by covering most of the commonly encountered problematics while developing an application (Form themes, FormEvents, DataTransformers, ajax forms, ...). But it would actually not be restrained to the form component. What do you think of such a demo application ? |
@ogizanagi, I think it's a great idea. |
@ogizanagi 👍 take care of beginners is good, but missing "commonly encountered problematics". |
@ogizanagi My worry is maintenance - i.e. who will create this and maintain it? But I'm very interested in this idea. To go further, I'm interested in having cookbook articles about this kind of stuff that is actually backed by annotated project code (e.g. "Go and see the code for this cookbook article here: http://" |
@weaverryan : Sorry for the late answer. I didn't see your comment before. The idea is to provide a fully working "real-life" symfony application (like the current demo, but with intensive use of the components), along with some comments in the code and short articles explaining each of the components aspects it involves. That's something we recently talked internally and with @webmozart. I started this week and will certainly keep improving it on my time. The codebase currently involves samples for the following elements:
However, we cannot offer through this idea something as efficient as you could have in a lesson with a dedicated exercise, nor having parts of the application dedicated to illustrate a symfony.com cookbook. Because isolating and finding "features" for each of the components capabilities in a real-life application is quite complex :/ . |
I'm -1 for using entity inheritance in the demo project. Entity inheritance is something that all Doctrine recommend to avoid. It comes with many drawbacks (many of them related to performance), so we should not encourage using it. There are cases where using this feature is valid, but in most cases, it is a bad idea. |
@stof thanks for commenting on this. I didn't know that inheritance was so discouraged. In fact, the Doctrine documentation doesn't say anything about that. I've created a PR to the Doctrine docs: doctrine/orm#1486 |
Let's close this because since it was created, we've added a ton of features, including event listeners, subscribers and most of the features that @ogizanagi outlined. |
With symfony 2.0, I had a lot of problems with the event driven design.
I took a long time until I understand the benefit of using the event dispatcher.
in my opinion, in the symfony best practices, there should exist a good example how to use the event dispatcher.
The controller listener is needed, but not a good example.
https://github.com/symfony/symfony-demo/blob/master/src/AppBundle/EventListener/ControllerListener.php
maybe we can add an example like this
https://github.com/symfony/symfony-demo/blob/master/src/AppBundle/Controller/BlogController.php#L64
the controller can be reduced, if we dispatch a new.user event and add at least one event listener who is persisting the data to the database and maybe another one, which is doing something else.
there exists a lot of blog articles about thin controller, maybe we should try to implement a good case in the symfony demo.
what do you think about that?
The text was updated successfully, but these errors were encountered: