Thus C.R.U.D. is C.R.A.P.

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.

You are correct :)

That is why I am rarely using the CRUD generator.

It is just a template.

And underwhelming out of the box.

I have used the GIIX extension before - Yii 1 - but haven’t tried a GII extension for Yii 2 yet.

You could try this: https://packagist.or…i2-enhanced-gii

If you find yourself not satisfied over and over, it is actually quite easy to write your own, custom GII extension.

You can base on one of the available GII extensions for Yii2, of course.

Most of the time, I am just coding it, because - most of the time - my Yii 2 applications does not fit into one mold.

I agree.

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?

The model classes do respect the data types of their fields up to a certain extent.

In general you might have to get used to the thought of working with a programming language that is not type-safe. And all the consequences of that.

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.


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.

If you are not satisfied with the standard ones.

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

such as

I did this 7 years ago using ASP.NET, but I don’t like having to fight with ASP.NET hosting servers, which are flaky and troublesome.

I will experiment with various extensions. I’m not experienced enough yet to write a new one.

.NET is quite different from PHP.

.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. :)

This is good to know. I was worried I would get drowned in the complexity of my own application. Thanks!