© 2015 X2Engine Inc.
Difference between revisions of "Introduction To Development"
X2WikiAdmin (talk | contribs) (→File Structure) |
X2WikiAdmin (talk | contribs) (→MVC In a Nutshell) |
||
Line 14: | Line 14: | ||
=== MVC In a Nutshell === | === MVC In a Nutshell === | ||
− | A request to the server translates to the instantiation of a controller class. Which controller is instantiated depends upon the [http://www.yiiframework.com/doc/guide/1.1/en/basics.controller#route route], which contains the first part of the controller class's name with the first letter in lowercase. Then, the method of the class whose name begins with "action" is run based on the [http://www.yiiframework.com/doc/guide/1.1/en/basics.controller#action action ID] of the request URL. Actions which respond with content will then typically make a call to [http://www.yiiframework.com/doc/api/1.1/CController#render-detail render] or [http://www.yiiframework.com/doc/api/1.1/CController#renderPartial-detail renderPartial], methods inherited from the [http://www.yiiframework.com/doc/api/1.1/CController#renderPartial-detail CController] class. The [http://www.yiiframework.com/doc/guide/1.1/en/basics.view view file], specified by the first argument to that method, will then be used to display the content that is passed back to the client. | + | Relevant pages: [http://www.yiiframework.com/doc/guide/1.1/en/basics.controller Controller], [http://www.yiiframework.com/doc/guide/1.1/en/basics.model Model] and [http://www.yiiframework.com/doc/guide/1.1/en/basics.view View] in [http://www.yiiframework.com/doc/guide/ The Definitive Guide to Yii] |
+ | |||
+ | A request to the server translates to the instantiation of a controller class. Which controller is instantiated depends upon the [http://www.yiiframework.com/doc/guide/1.1/en/basics.controller#route route], which contains the first part of the controller class's name with the first letter in lowercase. Then, the method of the class whose name begins with "action" is run based on the [http://www.yiiframework.com/doc/guide/1.1/en/basics.controller#action action ID] of the request URL. As the action runs, it will retrieve data from the database using a model class. Actions which respond with content will then typically make a call to [http://www.yiiframework.com/doc/api/1.1/CController#render-detail render] or [http://www.yiiframework.com/doc/api/1.1/CController#renderPartial-detail renderPartial], methods inherited from the [http://www.yiiframework.com/doc/api/1.1/CController#renderPartial-detail CController] class. The [http://www.yiiframework.com/doc/guide/1.1/en/basics.view view file], specified by the first argument to that method, will then be used to display the content (contained in the model) that is then passed back to the client. | ||
=== File Structure === | === File Structure === |
Revision as of 00:04, 13 September 2012
Contents
Fundamentals
Dependencies
X2EngineCRM is built using the following frameworks; see their respective documentation for information about their use.
Yii Framework
Yii Framework is a PHP framework based on the time-tested MVC (Model-View-Controller) design methodology, which is of particular importance in understanding how requests translate to the execution of class methods.
jQuery and jQuery UI
Most of the Javascript in the codebase, including Yii Framework itself, depends on jQuery in some way or another. Thus, for front-end design (especially design that involves asynchronous content loading via AJAX) it is essential to understand the usage of this library. In many cases, Yii Framework provides certain utilities for constructing HTML elements and jQuery-based scripts, and it is thus also important to first search for effort-saving devices available in Yii Framework before writing something from scratch. In particular, CHtml contains methods such as ajaxButton, and the subclasses of CJuiWidget can be used to easily construct most common jQuery UI elements and seamlessly integrate them with Yii as input fields.
How a Request Translates To an Action
MVC In a Nutshell
Relevant pages: Controller, Model and View in The Definitive Guide to Yii
A request to the server translates to the instantiation of a controller class. Which controller is instantiated depends upon the route, which contains the first part of the controller class's name with the first letter in lowercase. Then, the method of the class whose name begins with "action" is run based on the action ID of the request URL. As the action runs, it will retrieve data from the database using a model class. Actions which respond with content will then typically make a call to render or renderPartial, methods inherited from the CController class. The view file, specified by the first argument to that method, will then be used to display the content (contained in the model) that is then passed back to the client.
File Structure
Modifying the codebase requires an understanding of where the relevant files are located. All PHP files used in the web application, which don't belong to the framework, are under the protected/ directory. This directory is not accessible from the web per the access rules defined in the .htaccess file; rather, these files are executed by the framework as the application runs. Within protected are the following directories:
- components/
- Miscellaneous classes used throughout the application, especially those which are extended by other classes.
- config/
- Core configuration files for the web application.
- controllers/
- Base-level controller classes.
- data/
- (Currently unused) Miscellaneous data files, i.e. SQL scripts
- extensions/
- The designated folder for storing third-party classes.
- messages/
- Files containing translations of messages within the application (used by Yii::t)
- models/
- All core/base level model classes.
- modules/
- Self-contained modules. Most of the subdirectories here contain modules whose names appear in the main menu. Each subdirectory typically has the same structure as the base application; they each will have directories named controllers, models and views. See Fundamentals:Module in the definitive guide to Yii for more information.
- runtime/
- (For the application's use) Temporary files written to by the application
- tests/
- The designated directory for storing unit tests.
- views/
- View files corresponding to base-level controllers.