application, we may divide it into several modules, each being developed and maintained separately. Some commonly used features, such as user management, comment management, may be developed in terms of modules so that they can be reused easily in future projects.
of models, views, controllers and other supporting components. In many aspects, a module resembles to an application. The main difference is that a module cannot be deployed alone and it must reside inside of an application. Users can access the controllers in a module like they do with normal application controllers.
reusable user components views/ containing view files for widgets controllers/ containing controller class files DefaultController.php the default controller class file extensions/ containing third-party extensions models/ containing model class files views/ containing controller view and layout files layouts/ containing layout view files default/ containing view files for DefaultController index.php the index view file
reusable user components views/ containing view files for widgets controllers/ containing controller class files DefaultController.php the default controller class file extensions/ containing third-party extensions models/ containing model class files views/ containing controller view and layout files layouts/ containing layout view files default/ containing view files for DefaultController index.php the index view file
reusable user components views/ containing view files for widgets controllers/ containing controller class files DefaultController.php the default controller class file extensions/ containing third-party extensions models/ containing model class files views/ containing controller view and layout files layouts/ containing layout view files default/ containing view files for DefaultController index.php the index view file
written to a specification. A component is an instance of CComponent or its derived class. Using a component mainly involves accessing its properties and raising/handling its events. The base class CComponent specifies how to define properties and events.
$document->textWidth=100; echo $document->textWidth; // we can only read textHeight echo $document->textHeight; // we can only write completed $document->completed=true;
example, when you write a new controller, you extend Yii by inheriting its CController class; when you write a new widget, you are extending CWidget or an existing widget class. If the extended code is designed to be reused by third-party developers, we call it an extension.
1. Download the extension from Yii's extension repository. 2. Unpack the extension under the extensions/xyz subdirectory of application base directory, where xyz is the name of the extension. 3. Import, configure and use the extension. Each extension has a name that uniquely identifies it among all extensions. Given an extension named as xyz, we can always use the path alias ext.xyz to locate its base directory which contains all files of xyz.
extensions, we would like to introduce the Zii extension library, which is a set of extensions developed by the Yii developer team and included in every release. When using a Zii extension, one must refer to the corresponding class using a path alias in the form ofzii.path.to.ClassName. Here the root alias zii is predefined by Yii. It refers to the root directory of the Zii library. For example, to use CGridView, we would use the following code in a view script when referring to the extension: