Several features which are critical for practical work

Hello all.

I have rather deep experience of using Yii in practical projects.

That’s why I would like to request several features to avoid creating them from the scratch in all new projects.

I’ll add some other requests later.


  1. Command-line model generation tool is marked as deprecated in your guide.

But I found it very useful for the following situation.

a) I created DB.

B) Generate all models for all db tables together by single execution of command.

c) Create models wrappers clasess for each model class and use further in the application these wrappers instead of direct using of model classes.

All customizations on model levels are done in wrappers, not in classes.

(Why??? See the next…)

d) At one day client/manager comes and asks "we decided to update 10 tables with adding many new fields/relations and removing old"

e) I tell "OK", do update in the DB, and… magic!.. with a single run of command-line tool I regenerate all models classes.


a) I don’t need to create new validation rules and new definitions of relations for each model class after each update.

All is generated automatically.

B) And at the same I keep all manual customizations which I did on model-level in my wrappers.

Important detail!

Steps D and E happen EVERY WEEK, or at least every 2-3 weeks.

Result: we save several hours of work per week.


  1. We need to integrate some images manipulation library with rich set of tools.

  2. Distr-builder for web-based products.


a) extract from dev/test server all files for distr

B) merge with some set of directories/files

c) remove all technical comments, and add copyright comments

d) zip all

  1. Post deployment script that can be invoked from such servers as beanstalkapp and which does the following

a) automatically applies all migrations

B) calls "distr-builder" to generate build for each revision

  1. Methods for CFileHelper
  • deleteDirectory

  • findDirectories

  1. Ajax-based models manager.

Can be inserted into every page and configured for any model class.

Performs all CRUD and pagination/sorting operations by ajax.

Has customizable UI.

  1. Auto prefixing of Html-elements in forms by setting prefix in beginForm() options.


on main page we have full form for User class;

but in quick launch bar we have link for opening of Ajax-ed limited version of the same form for User class.

So we will have conflict of HTML elements’ id-s and names in result!

Both forms are autogenerated!

So the only way to solve this conflict is to add prefixes into one of forms.

Now prefixing feature can be implemented only by customizing CHtml class = rewriting of framework.

  1. CFileHelper

findFilesAndDirectories() method

  1. Frontside models manager.

Difference between it and "Ajax-based models manager" mentioned above:

all results of CRUD operations made by user are not saved immediately to server,

they are saved only by submitting the whole form wrapping this manager with many other controls.

This manager is ideal for situations when we need to manage for example several phones/emails for a user.

Note, each phone/email may have several attributes.

  1. Common base model class for managing

a) attributes which are common for all models in DB

  • createdByUser

  • modifiedByUser

  • creationDatetime

  • modificationTimestamp


it is a good idea to automate creation of such fields with required relations and their management;

usually such fields exist in every complex application

b) custom fields whose definitions and values are stored not in main tables, but in separate special tables;

(short description is "virtual table columns")

usually this feature is done to allow end-user customize object-model of the application

  1. Built-in DB Schema manager with customizable UI

Many applications explicitly or implicitly require in admin area such feature that should be only slightly customized to reflect in UI terminology of the application field.

  1. Built-in SQL queries builder connected to some graphic library for charts generation.

The same situation as with DB schema manager.

Many applications explicitly or implicitly require this feature in some form.

  1. Mail protocols wrapper-classes for working with all popular mail servers.

Ideally should have UI for quick implementation of built-in e-mail client.

  1. Smart (!!!) Ajax-controls = link, button, file upload, multiple file upload.

(I have not checked the latest versions yet, but those which you had 6-12 months ago were not smart.)

a) all should have built-in customizable animated loader

b) all should reflect each possible state and each possible state change

  • enabled/disabled

  • sending request

  • server is down, no answer for N seconds

  • successful result from server

  • error result from server

  • message result from server

  • communication error

c) custom event handlers for each state change mentioned above

  1. Installation wizard (or even builder of such wizards) for web-based products.

a) auto-applying of all migrations

b) seeding db from some script or data file

c) checking Yii requirements + some custom requirements

d) all other features which are present in typical simple desktop installation wizards builders (like InnoSetup for example)

Addition for 10b item listed above.

These "virtual columns" should be completely processed inside common base model class, and look for business logic as standard columns with validation rules, labels etc.

  1. Customizations of autocomplete widget that tracks (!) changes made in input field by receiving from server id/name pair and comparing it with id/name pair stored in hidden fields which were taken from server on initial load of the form.

The following situations should be tracked:

a) - create form, user chooses value in auto complete, saves all

  • update form, user types value in auto complete instead of choosing one;

autocomplete should validate by ajax input value after leaving focus whether it is existing value in db or not;

if not it should mark this fact in UI somehow;

  • update form, user chooses or types existing value, hidden fields should be automatically updated

the general sense: server-side on submit should receive auto-found ID in hidden field, but not text from input field

b) submission of the form should be locked while autocomplete makes ajax request to server;

note that form may have several (!) such autocomplete widgets

  1. Ajax-based relations builder popup.

Should be configurable for

  • building relations between any models classes

  • returning on main page html code with the list of related models

  • having internal search form

  • having internal controls for whole CRUD logic for related models and for additional attributes of relations

A typical example:

assign user to several groups, employee to several departments

  1. Built-in color picker widget.

  2. Debug logs reader with automatic color mark-up for different types and sources of messages.

  1. Active money field in CHtml
  1. Base class of form for operating simultaneously with many models.


a) validation of all models together with displaying hierarchical error message in case of wrong input data

B) avoid validation of foreign keys that were not definitely created yet at the moment of validation

c) saving all models together in single transaction

d) up to 3 levels of nesting in hierarchy of models, unlimited number of models in any level

e) tight integration with "Frontside models manager" mentioned above

f) tight integration with CHtml feature for prefixing controls’ names and ids - definitely in this case we will have many controls for the same model class - so standard algorithm for ids/names generation will not work - we will need prefixing

h) this prefixing should not prevent mass assignment of attributes on server-side

  1. Multi-step form for managing many models simultaneously.

It is a more complex case of item 21 mentioned above.

a) some parts will be implemented as 21

b) some parts will cause update of form on main page with return back again and restoring all input data from session

c) and moreover, for some elements "Ajax-based relations builder popup with Caching!" should be used - it means that all CRUD operations performed in Ajax-based popup will not be immediately done on server, but will be cached somehow inside hidden fields on form with a possibility to open popup again and again for additional edits…

And results of all these operations should be sent for saving to server by single click on main button Save

No intermediate saving should be done.

  1. Built-in YUI compressor for js/css files.
  1. Attributes of model classes with type Uploaded File (in fact varchar(255) with a setting for model that contains folder name). Uploading of new file, deletion of old one, optional unique renaming or check for existence of the same file, types control, size control - all these tasks should be performed automatically and should be invisible.


Huge list, Kamil. Thanks for it. Will check it in detail later today.

Sorry for bad English and non-clear explanations. I typed all very quickly.