Hello everyone, this is my first serious post. Despite the post title, I do not wish to insult or upset anyone. I think I’m missing something really obvious, so please point me in the right direction.
First, my background is databases. I’m a database programmer and have been developing database applications for over 20 years. Mostly I use Microsoft Access and SQL Server, but more recently I have tried my hand at web-based databases, since Access clearly cannot do web site databases.
I use a little-known RAD tool called Mustang, which has a database dictionary (Yii2 doesn’t seem to have this yet) and it allows me to create a working database with relations, foreign keys, views and so on, and allow the user to start capturing and editing data in a short time.
Naturally I thought that Yii would be able to do the same thing with my data structure on MySQL, but my first reaction to a standard Gii build was “This CRUD is crap! No drop-down boxes for foreign keys. No checkboxes for boolean fields. All text fields are the same length. I can’t give this to the customer!”
I assume I’m not the first person to have this reaction, so what am I missing? I’m going to experiment with YiiBooster, but is this the right direction, or should I look at something else? All guidance and suggestions would be greatly appreciated.
Gii’s CRUD generator is surely a good thing, IMO. But you can not compare it with the counterparts for desktop application like Access and .NET. It misses several (and critical) functionalities.
I usually use CRUD generator mainly for master maintenance pages for admin users. They can be somewhat simple and straightforward. Of course I have to modify some input fields, changing text inputs to dropdowns, checkboxes, radiobuttons and so on.
But for the main pages for the end users, well, the CRUD generator is not that useful. It surely gives you a working page with minimum functionality, but it’s far from enough for end users.
OK, so the GII generator is basically useless. What about the rest of YII? Do the classes and such know about the data structure enough to not screw up dates or boolean fields, or is everything just a text field?
You need to understand that there can’t be one size fits all. Yii is extremely flexible.
The Yii way is to take the standard Gii generator and customize it to fit your needs. Or find a community ‘generated’ generator that fits your project the best.
Are you serious?
Yes, of course. Yii is intelligent enough to be aware of the data structure and dates and boolean fields.
Follow the link to the gii extension that I posted above and follow it all the way to the github repository where you can see pictures of what it can generate.
I am not using it, because I don’t want it to generate that kind of CRUD for my projects.
If Yii did do all kinds of magic out of the box, then we would all have to fight with Yii whenever we wanted to do something different.
I am happy that Yii is better than that.
EDIT:
You can view the Gii CRUD generator that ‘ships’ with Yii as a starting point.
Same goes for the project generators (basic and advanced).
I usually create my own project generators, but haven’t yet had the need for a custom gii generator…
Anyway, there are probably Gii generators and project generators already created that could appeal to you.
Thanks for this advice, and your other comments. Much appreciated.
I’m used to starting off with fully functional generated CRUD, and the Gii stuff is extremely substandard. Take a look at the generated forms at www.mustang.co.za
.NET has the upper hand when it comes to code insight, retrospection, etc.
Yii is using convention a bit more, and it starts with the database (schema) - if you got that right (naming, namely), then Gii (including the extensions) will actually generate fairly complete skeletons.
It is fairly straight forward to generate forms like the one you linked to. And I would say, it is also fairly easy to generate forms that kicks it’s behind.