-
-
Notifications
You must be signed in to change notification settings - Fork 422
CRUD generator? #3
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
Comments
Maybe. The old generator - at least after years of existing - generated some ugly code. Obviously... we shouldn’t let that happen again. But... i guess it is a nice thing to have. We could wait for people to ask for it... but if we know they’ll want it, why wait. |
yes please :) 😃 |
It would be a nice feature to have 👍 |
Yes we need but with more clearly... Sensio Generator is ugly, redundant and repeated code anywhere |
How is the old CRUD generator used nowadays? I mean, isn't an admin CRUD generator like EasyAdmin more efficient & simpler? Or is it really used to bootstrap code in an application? |
The crud Generator is used often in my projects. I would really love a modern crud Generator here. |
I'm about to start a new project with symfony 4, and waiting for the CRUD generator feature! I'm a freelancer and this would help me a lot to bootstrap apps |
I like the idea of a CRUD generator, the old one provides enough basic utility for a functional starting point. When looking at the generated code, the PHP-code is just a basic Symfony controller, which seems fine. The templates, on the other side, are something to be more opinionated about. Obviously it would be unwise to include CSS with the generated code as it would increase complexity for the user. One solution to this could be a mechanic where third-party bundles are allowed to override the skeleton files (#33). A dedicated bundle (like a Bootstrap bundle) would be able to provide more modern templates. The Bootstrap example is just one of the use cases, an official bundle would be unlikely to make everybody happy on this. |
yesss!! |
I consider this an extremely important feature to have; "old" generator bundle does not provide ugly code, but it has come issue I personally handle very time I use it:
so +1 for a new generator, hopefully extendable giving the possibility to the user to choose options above |
👍 for CRUD |
That would be great to have all important commands in one bundle. 👍 |
My 2 cents: If you need a basic CRUD generator, why don't you use EasyAdminBudle? It's so simple to set-up and to configure. So for me, except for a training session, the CRUD generator is useless. Anyway, This should be quite easy to develop it, But only if we support 0 options (we should only support Doctrine + Twig + no pagination + no filtering) |
When someone mentions "CRUD generator", we think about the old symfony 1 admin generator or SonataAdmin, etc. But we can't make that because:
However, we could forget about the templates and other resources and only generate the controller part. This could be similar to the Rails routing resources. For example, if you put See http://guides.rubyonrails.org/routing.html for details. |
CRUD != admin generator. There is nothing in common between the 2. A CRUD generator is something that give you some code for you to modify. You own the code. And admin gen is something that let's you configure some generic code that you don't own. We do have admin gens, and SensioGeneratorBundle is a CRUD generator. The latter is what we should replace. |
another approach to reduce the CRUD boilerplate could be something similar to Djangos Class Based Views. |
In the past: |
@ksn135 Not sure I understand your comment here. In Symfony 4, you have several admin generators... which are different from CRUD generation (see my previous comment). |
I vote in favor of CRUD 😁 |
It sounds like this is the first thing people are missing when experimenting with Symfony 4. I think that in addition to @fabpot's argument, it's important to point out that we're trying to make it as easy as possible to create your own makers. Anybody who wants to customize the output for the CRUD generator is free to do so and could even publish it as a bundle. Built-in makers should remain as simple as possible. |
The idea is to have a single controller, views, etc., from which the generated code extends. |
Hi everybody,
In some of my apps, I have around 100 tables, and it's very useful for me to generate the crud for all my tables and then juste customize the twig part. Without that option, it would increase the time needed to develop it. Other thing that is not linked, is it possible to add fields to an entity without having to get through the PHP file as we used to do in sf3 with command line? |
I'd love to have a templates generator like generate:doctrine:crud... and I'd love that make:entity works like generate:doctrine:entity and request the entity's fields and generate the annotations for that entity... I feel that in S4 I need write more code than in the previous versions. Greetings! |
@fabpot , most of us may have realized that a CRUD generator is not an admin generator. Regardless, I'm assuming that a CRUD entity generator will make life easier for many developers. Are there concrete plans to integrate something like this? |
We are going to add an entity generator and we are probably going to add a CRUD generator like in the old SensioGeneratorBundle. When? No estimate date. We don't have enough resources to do all the things we want to do. |
It's possible and easy to create your own crud generator, as I did for some of my projects. This is not a "bundle" but a small set of programs I launch like this: php bin/createForm. For the moment it generates all the CRUD with either a very simple template (like it was done before) or a self-made template we use in our company. |
Hi all. Need your advise. I have working crud generator as extension to maker-bundle, but for now generated code is not very beautiful. I can continue working on the bundle, if it is needed. But I don't know what is the best solution for generated code. |
@sadikoff the best solution might be to apply your code directly to this bundle and create a PR for the CRUD generation :). If you want to put in some work to build this command, we can help you and it will get done much faster. |
@weaverryan thx I'll prepare PR for this feature tomorrow. |
…averryan) This PR was merged into the 1.0-dev branch. Discussion ---------- Add make:crud & improve make:form commands Hi all, ## Improved make:form command Main improvement is that command works in two ways. First way simple, it just generates skeleton form class and user can do with it whatever he want. Second way is generation from entity class. Generator checks if entity exists and ask user if he wants to generate form from entity or user can use `--entity` flag if he knows that entity exists. ### Generation features: - Simple skeleton form class - Doctrine entity form class ### Examples: **Simple class generation** ```bash root@striX: ~/project_root# bin/console make:form The name of the form class (e.g. GentleElephantType): > SimpleForm Enter the class or entity name that the new form will be bound to (empty for none): > created: src/Form/SimpleFormType.php Success! ``` **Entity form generation** ```bash root@striX: ~/project_root# bin/console make:form The name of the form class (e.g. GentleElephantType): > EntityFormType Enter the class or entity name that the new form will be bound to (empty for none): > Entity created: src/Form/EntityFormType.php Success! ``` Closes: #114 ## New make:crud command Want to introduce `make:crud` command it is similar to doctrine:generate:crud from SensioGeneratorBundle. All you need to generate cool crud is Entity :) ### Features - complete crud generation ### Example: ```bash root@striX: ~/project_root# bin/console make:crud SweetFood created: src/Controller/SweetFoodController.php created: src/Form/SweetFoodType.php created: templates/sweet_food/_delete_form.html.twig created: templates/sweet_food/_form.html.twig created: templates/sweet_food/index.html.twig created: templates/sweet_food/show.html.twig created: templates/sweet_food/new.html.twig created: templates/sweet_food/edit.html.twig Success! ``` Closes: #3 Commits ------- 2683114 some improvements 2ec8ff0 fix form variables 0d9e637 added validation on arguments ada7db0 fix phpcs f740e2e fix variables to follow official recommendations b3bf878 some make:form improvements + experiments 204f5aa final fix for skeleton templates 96d54a7 Merge branch 'master' of https://github.com/sadikoff/maker-bundle 38b2864 Merge remote-tracking branch 'upstream/master' ee98865 making test name less specific so we can run only it ba0438f phpcs fix 3d319bd some skeleton improvements da37780 Merge remote-tracking branch 'upstream/master' 2ebff8c fix cs and improvements according to review request 772f0db fix make:form 44b7851 completed improvement of make:form command db30634 added tests for crud testig ad8a4fb fix tests on appveyor e8eabd6 Merge remote-tracking branch 'upstream/master' 60c0005 php cs fix 404c38f update all to lastest bundle code cc4b758 Merge remote-tracking branch 'upstream/master' 1b95509 add csrf dependency it's necessary for delete action in crud and for better security 52a20bb improve make:crud command to use make:form logic for form generation e24b22c fix to use with php 7.0 7555a3a improved make:form command 4045695 removed unnecessary code 7ed6b8b improved tests 3787739 cs fix 71d2e90 some code refactoring + testing new GeneratorHelper to simplify skeleton templates 6f1c296 array style fix 96f2af2 Merge remote-tracking branch 'upstream/master' ab0a0dc Merge remote-tracking branch 'upstream/master' 422d31b Merge branch 'master' of https://github.com/sadikoff/maker-bundle ff9a08d some fixes 42047a6 fix Token parameter name in delete action 5157e0a fix interception of /new url by show action 7783313 fix fobpot.io cs 31d9e81 fix templates generation with date fields in entity 1b0f17a test remove some phpdoc comments to pass travis.ci 207d8be add exception if entity doesn't exists 478b457 fix fabpot.io cs 3 791241d fix fabpot.io cs 2 9961f43 fix fabpot.io cs f189efd fix tests 8c98b45 trying tests 2 08d4bc5 trying tests 8e9bd67 fix skeleton according to community recommendations e9f91ef add MakeCrud class to makers.xml 6cdda8f final fix fabpot.ci CS 4c0b639 fix fabpot.ci CS bf9a5c1 make:crud command initial commit
This bundle actually does not replace the current generator bundle as it was more focused on a CRUD generator. Is it something we want to do here as well?
The text was updated successfully, but these errors were encountered: