More folder conventions

I’d recommend a folder convention. Not only for models, views and controllers, but also for widgets, behaviors, static function helper classes, 3rd party classes like swiftmailer etc.

So the default folder structure could look like this:




...

|

+-Components

  |

  +- Widgets

  |  |

  |  +- WidgetFileA.php

  |  +- WidgetFolderA

  |  |  |

  |  |  +- views

  |  +- WidgetFileB.php

  |  +- WidgetFolderB

  |     |

  |     +- views

  |

  +- Behaviors

  |

  +- Helpers

  |

  +- Validators

  |

  +- Vendors

  



(I might missed some folders)

There could also be path shortcuts like ‘ext.’ for application.extension (e.g. ‘behavior.’, ‘helper.’, ‘validator.’, ‘vendor.’, ‘widget.’)

The "Helpers" folder contains global static helper classes, the "Validators" folder contains custom model validations.

Since a widget consists of a php file and some libs and views you don’t want to drop everything into the components folder. I recommend a separate file and a same named folder containing all the widget related stuff (like mentioned above)

What do you think?

I don’t think Yii should force these. Your component structure can be easily put into extensions so alias will be ext.behaviors.

No, I wont force the user to use this structure, but use it as an overridable convention

It looks cleaner, but it comes with a drawback: You would have to import more directories (which Yii adds to PHPs include path). So more directories need to get scanned when a class file is missing. That’s why i don’t think, Yii should use this structure for generated apps by default.

I won’t use the autoloader for this, but search within the defined folders. So if one writes


<?php

$this->widget('thumb');

Yii would look for a file called thumb.php in "application.components.widgets"