Skip to content
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

Command for generating login and register. #25406

Closed
fiher opened this issue Dec 8, 2017 · 3 comments
Closed

Command for generating login and register. #25406

fiher opened this issue Dec 8, 2017 · 3 comments

Comments

@fiher
Copy link

fiher commented Dec 8, 2017

Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no
Symfony version 4.0.1

First off - Thank you for developing and managing Symfony! This is my first ever contribution after using symfony for more than a year.

At the beginning of my experience with Symfony and currently after the new version I have been creating lots of small projects to test new stuff and play with the framework. I have always found it really annoying that I have to do the same login and register. First I create my User entity and then I edit routes.yml, security.yml and so on...I suppose that you are familiar with the procedure but if not here is the documentation Login Form and Register form.

I have always found it annoying that the register documentation uses RegisterController and login documentation uses SecurityController , but this is not what I am talking about here.

Could there be any command to be executed that does this? The reason behind this is that it is really repetitive work which is always the same (unless some really really specific occasion arrives) and it is mostly magic. In the documentation its not really explained how it works and you have to figure it out by yourself by looking at the stack trace and debugging. Which means that for new programmers like myself there isn't really a point of doing it each time and we do it really often because we train and make demo projects all the time.

Requirements for the project in order to run the command

  • Having symfony project structure
  • Having entity which extends UserInterface

Options to the command

  • algorithm: The algorithm used. Default is bcrypt
  • withsalt: Defines that you want your algorithm to use salt (if it uses salt)
  • register path: The route to be used for login.Default is "/register"
  • login path: The route to be used for login. Default is "/login"
  • check path: The route to be used for check login. Default is "/login"
  • entity: The entity to be used for login and register. Must implement UserInterface. Default looking for User

The idea is that the code needed is already in the documentation from the twig to the controller and configuration. It just needs to be auto generated rather than copy pasted every time.

It doesn't seem as much work to be implemented since the code needed is already in the documentation and I would love to give it a try, but I have never contributed to a framework before or any project of such scale. If there is anyone good enough to guide me I would love to contribute to Symfony and if it goes well implement other features as well. Currently I can't seem to find an entry point for such function to be implemented. I know how to write to files and create files and such, but I don't know where should I write my function and how to properly check if the project structure is valid. If anyone is willing to help me for my first contribution to this project I would be more than happy to continue contributing. If not - I hope the community likes the idea and implements it so that I can use it.

@linaori
Copy link
Contributor

linaori commented Dec 9, 2017

This sounds pretty much like the FOS User Bundle.

However, if you wish to create some sort of a generator, I would highly advice to make the generated code follow good practices, thus not having an entity implement the UserInterface.

@fiher
Copy link
Author

fiher commented Dec 9, 2017

@iltar Thank you for this article. I indeed didn't know that implementing the UserInterface is a bad practice. As for FOSUserBundle - You don't really generate login and register...you just download them with the bundle. The one thing I dislike about FOSUserBundle is that to a new user it looks like magic. It looks like magic anyway, but with FOSUserBundle it is even more so.

My idea with the generated login and register is to make Symfony more....user friendly. With auto generated code there is no need to hide anything which will make Symfony easier to understand.

@javiereguiluz
Copy link
Member

I indeed didn't know that implementing the UserInterface is a bad practice

It's not a bad practice. Iltar thinks so ... and others agree ... but some others disagree.

In any case, I like your comments a lot. Recently we introduced a new Symfony Maker Bundle where we are creating commands that generate boilerplate code. One of our TODO things is to add commands that simplify the security part of Symfony apps. For example: symfony/maker-bundle#41

So, I'm closing this issue because we can't fix it in Symfony core repository, but please add your comments and ideas in the MakerBundle repository to help us fix this problem. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants