Yii  [ easy, efficient and extensible  php framework] Honeyson Joseph D Roll no : 511 S5 MCA TKMCE  KOLLAM
introduction -  Yii  is a high-performance component-based PHP  framework for developing large-scale Web applications -  Y...
FUNDAMENTALS OF  Yii <ul><li>Model-View-Controller (MVC) </li></ul><ul><li>Entry Script </li></ul><ul><li>Debug Mode </li>...
FUNDAMENTALS OF  Yii Model-View-Controller (MVC) MVC separate business logic from user interface considerations to easily ...
FUNDAMENTALS OF  Yii Entry Script   Entry script is the bootstrap PHP script that handles user requests initially.  It is ...
FUNDAMENTALS OF  Yii Application   Application represents the execution context of  request processing.  The application s...
FUNDAMENTALS OF  Yii Controller A controller is an instance of CController or its child class created by application . Whe...
FUNDAMENTALS OF  Yii Filter Filter is a piece of code that is configured to be  executed before and/or after a controller ...
FUNDAMENTALS OF  Yii Model A model is an instance of CModel or its child class.  Models are used to keep data and their re...
FUNDAMENTALS OF  Yii Layouts Layout is a special view that is used to decorate  views.  It usually contains portions of  u...
Static structure of an Yii application
A Typical Workflow OF  Yii
Workflow OF  Yii(contd..) <ul><li>A user makes a request with the URL http://www.example.com/index.php?r=post/show&id=1 an...
Workflow OF  Yii(contd..) <ul><li>The application creates an instance of the requested controller to further handle the us...
Workflow OF  Yii(contd..) <ul><li>The view reads and displays the attributes of the  </li></ul><ul><li>Post model. </li></...
CREATING  AN  Yii  APPLICATION For creating Web application we use a powerful  yiic   tool which can be used to automate c...
CREATING  AN  Yii  APPLICATION(contd..) Step 0. Preparation After downloading and installing the Yii framework, run a simp...
CREATING  AN  Yii  APPLICATION(contd..)
CREATING  AN  Yii  APPLICATION(contd..) Step 1. You Create the Database While Yii can virtually eliminate most repetitive ...
CREATING  AN  Yii  APPLICATION(contd..) Step 2a.  Yii Generates the Model Classes Using the built-in Web-based code genera...
CREATING  AN  Yii  APPLICATION(contd..)
CREATING  AN  Yii  APPLICATION(contd..) Step 2b. Yii Generates the CRUD Code Using the  code generator, we can further gen...
CREATING  AN  Yii  APPLICATION(contd..)
CREATING  AN  Yii  APPLICATION(contd..) Step 3. You customize the code to fit your exact needs Finally we customize the co...
CREATING  AN  Yii  APPLICATION(contd..)
features of  Yii -  Database Access Objects (DAO), Query Builder Yii allows developers to model database data in terms of ...
features of  Yii(contd..) -  Form input and validation Yii makes collecting form input extremely easy and safe. It comes w...
features of  Yii(contd..) -  Skinning and theming Yii implements a skinning and theming mechanism that allows you to quick...
features of  Yii(contd..) <ul><li>Automatic code generation </li></ul><ul><li>Yii provides a set of intuitive and highly e...
features of  Yii(contd..) <ul><li>Error handling and logging   </li></ul><ul><li>Errors are handled and presented more nic...
Advantages of  Yii framework <ul><li>Component based </li></ul><ul><li>MVC </li></ul><ul><li>DOA/Active record </li></ul><...
Disadvantages of  Yii framework It  is written  in approach  that does not support the most innovative, modern advantages ...
Conclusion Yii does not need to be installed under a Web-accessible directory.  An Yii application has one entry script wh...
References   [1]  www.code.google.com/yii/  [2] Wikipedia – Yii [3] http://www.yiiframework.com
Upcoming SlideShare
Loading in...5
×

Yii php framework_honey

6,904

Published on

not full covered..its just intro from its tutorial

Published in: Technology
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
6,904
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
313
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide

Yii php framework_honey

  1. 1. Yii [ easy, efficient and extensible php framework] Honeyson Joseph D Roll no : 511 S5 MCA TKMCE KOLLAM
  2. 2. introduction - Yii is a high-performance component-based PHP framework for developing large-scale Web applications - Yii is a generic Web programming framework, used for developing virtually all sorts of Web applications - Yii is a Model View Controller framework
  3. 3. FUNDAMENTALS OF Yii <ul><li>Model-View-Controller (MVC) </li></ul><ul><li>Entry Script </li></ul><ul><li>Debug Mode </li></ul><ul><li>Application </li></ul><ul><li>Application Base Directory </li></ul><ul><li>Application Component </li></ul><ul><li>Controller </li></ul><ul><li>Action </li></ul><ul><li>Filters </li></ul><ul><li>Model </li></ul><ul><li>View </li></ul><ul><li>Layout </li></ul><ul><li>Widget </li></ul>
  4. 4. FUNDAMENTALS OF Yii Model-View-Controller (MVC) MVC separate business logic from user interface considerations to easily change each part without affecting the other. In MVC , model represents the data and the business rules; view contains elements of the user interface such as text, form inputs; and the controller manages the communication between the model and the view. Yii uses a front-controller, called application, which represents the execution context of request processing.
  5. 5. FUNDAMENTALS OF Yii Entry Script   Entry script is the bootstrap PHP script that handles user requests initially. It is the only PHP script that end users can directly request to execute Debug Mode Yii application can run in either debug or production mode according to the constant value YII DEBUG. By default, this constant value is defined as false, meaning production mode. To run in debug mode, define this constant as true before including the yii.php file
  6. 6. FUNDAMENTALS OF Yii Application   Application represents the execution context of request processing. The application singleton can be accessed at any place via Yii::app(). Application Base Directory Application base directory refers to the root directory that contains all security-sensitive PHP scripts and data. By default, it is a subdirectory named protected that is located under the directory containing the entry script
  7. 7. FUNDAMENTALS OF Yii Controller A controller is an instance of CController or its child class created by application . When a controller runs, it performs the requested action which usually brings in the needed models and renders an appropriate view An action can be defined as a method whose name starts with the word action. An action class and ask the controller to instantiate tasks when requested Action
  8. 8. FUNDAMENTALS OF Yii Filter Filter is a piece of code that is configured to be executed before and/or after a controller action executes. Example, an access control filter may be executed to ensure that the user is authenticated before executing the requested action; a performance filter may be used to measure the time spent in the action execution.
  9. 9. FUNDAMENTALS OF Yii Model A model is an instance of CModel or its child class. Models are used to keep data and their relevant business rules. A model represents a single data ob ject. It could be a row in a database table or a form of user inputs View A view is a PHP script consisting of mainly elements of user interface. View contain PHP statements, but it is recommended that these statements should not alter data models and should remain relatively simple.
  10. 10. FUNDAMENTALS OF Yii Layouts Layout is a special view that is used to decorate views. It usually contains portions of user interface that are common among several views Widget A widget is an instance of CWidget or its child class. It is a component mainly for presentational purpose. Widgets enable better reusability in user interface. Widgets are usually embedded in a view script to generate some complex yet self-contained user interface. For example, a calendar widget can be used to make a complex calendar user interface.
  11. 11. Static structure of an Yii application
  12. 12. A Typical Workflow OF Yii
  13. 13. Workflow OF Yii(contd..) <ul><li>A user makes a request with the URL http://www.example.com/index.php?r=post/show&id=1 and the Web server handles the request by executing the bootstrap script index.php. </li></ul><ul><li>The bootstrap script creates an application instance and runs it. </li></ul><ul><li>The application obtains the detailed user request information from an application component named request. </li></ul><ul><li>The application determines the requested </li></ul><ul><li>controller and action with the help of an application component named URL Manager. </li></ul>
  14. 14. Workflow OF Yii(contd..) <ul><li>The application creates an instance of the requested controller to further handle the user request. The controller determines that the action show refers to a method named action show in the controller class. It then creates and executes filters (e.g. access controls, benchmarking) associated with this action. The action is executed if it is allowed by the filters. </li></ul><ul><li>6. The action reads a Post model whose ID is 1 from </li></ul><ul><li>the database. </li></ul><ul><li>The action renders a view named show with the </li></ul><ul><li>Post model. </li></ul>
  15. 15. Workflow OF Yii(contd..) <ul><li>The view reads and displays the attributes of the </li></ul><ul><li>Post model. </li></ul><ul><li>The view executes some widgets. </li></ul><ul><li>10. The view rendering result is embedded in a layout. </li></ul><ul><li>11. The action completes the view rendering and </li></ul><ul><li>displays the result to the user. </li></ul>
  16. 16. CREATING AN Yii APPLICATION For creating Web application we use a powerful yiic tool which can be used to automate code creation for certain tasks. For simpliy, we assume that YiiRoot is the directory where Yii is installed, and WebRoot is the document root of our Web server.
  17. 17. CREATING AN Yii APPLICATION(contd..) Step 0. Preparation After downloading and installing the Yii framework, run a simple console command “% YiiRoot/framework/yiic webapp WebRoot/testdrive “ to generate a skeleton Web application built with Yii. The application is fully functional, with nice features including user login and contact form. It is a good starting point for implementing more sophisticated features.   This will create a skeleton Yii application under the directory WebRoot/testdrive.
  18. 18. CREATING AN Yii APPLICATION(contd..)
  19. 19. CREATING AN Yii APPLICATION(contd..) Step 1. You Create the Database While Yii can virtually eliminate most repetitive coding tasks, you are responsible for the real creative work. This often starts with designing the whole system to be built, in terms of some database schema.
  20. 20. CREATING AN Yii APPLICATION(contd..) Step 2a. Yii Generates the Model Classes Using the built-in Web-based code generator, you can turn database table definitions into model classes instantly, without writing a single line of code. The model classes will allow you to access the database tables in an object-oriented fashion.
  21. 21. CREATING AN Yii APPLICATION(contd..)
  22. 22. CREATING AN Yii APPLICATION(contd..) Step 2b. Yii Generates the CRUD Code Using the code generator, we can further generate code that implements the typical CRUD (create, read, update, delete) features for the selected database tables. The generated code is highly usable and customizable, following the well-adopted MVC (model-view-controller) design pattern.
  23. 23. CREATING AN Yii APPLICATION(contd..)
  24. 24. CREATING AN Yii APPLICATION(contd..) Step 3. You customize the code to fit your exact needs Finally we customize the code to fit our exact needs. For example, to hide the password column on the user administration page, simply cross out the 'password' element shown in the following user admin view file: <?php $this->widget('zii.widgets.grid.CGridView', array( 'id'=>'user-grid', 'dataProvider'=>$model->search(), 'filter'=>$model, 'columns'=>array( 'id', 'username', 'password', 'email', array('class'=>'CButtonColumn'), ))); ?>
  25. 25. CREATING AN Yii APPLICATION(contd..)
  26. 26. features of Yii - Database Access Objects (DAO), Query Builder Yii allows developers to model database data in terms of objects and avoid the deadliness and complexity of writing repetitive SQL statements. <ul><li>Model-View-Controller (MVC) design pattern </li></ul><ul><li>Yii adopts the proven MVC architecture, which allows for clean separation of concerns. </li></ul>
  27. 27. features of Yii(contd..) - Form input and validation Yii makes collecting form input extremely easy and safe. It comes with a set of validates as well as numerous helper methods and widgets to simplify the task for form input and validation. <ul><li>Authentication and authorization </li></ul><ul><li>Yii has built-in authentication support. It also supports authorization via hierarchical role-based access control </li></ul>
  28. 28. features of Yii(contd..) - Skinning and theming Yii implements a skinning and theming mechanism that allows you to quickly switch the outlook of a Yii-power website. <ul><li>Layered caching scheme </li></ul><ul><li>Yii supports data caching, page caching, fragment caching and dynamic content. The storage medium of caching can be changed easily without touching the application code. </li></ul>
  29. 29. features of Yii(contd..) <ul><li>Automatic code generation </li></ul><ul><li>Yii provides a set of intuitive and highly extensible code generation tools that can help you quickly generate the code you need for features such as form input, CRUD. </li></ul><ul><li>Purely object-oriented </li></ul><ul><li>Yii framework sticks to strict OOP paradigm. It does not define any global function or variable. And the class hierarchy that it defines allows maximum reusability and customization. </li></ul>
  30. 30. features of Yii(contd..) <ul><li>Error handling and logging </li></ul><ul><li>Errors are handled and presented more nicely, and log messages can be categorized, filtered and routed to different destinations. </li></ul><ul><li>Security </li></ul><ul><li>Yii is equipped with many security measures to help prevent your Web applications from attacks such as SQL injection, cross-site scripting (XSS), cross-site request forgery (CSRF), and cookie tampering. </li></ul>
  31. 31. Advantages of Yii framework <ul><li>Component based </li></ul><ul><li>MVC </li></ul><ul><li>DOA/Active record </li></ul><ul><li>Form validation/re-population </li></ul><ul><li>Theming </li></ul><ul><li>Authentication and role-based access control </li></ul><ul><li>Strict OOP (PHP5 only to make full use of PHP object functionality) </li></ul><ul><li>Great documentation </li></ul><ul><li>Active community </li></ul><ul><li>Example project </li></ul>
  32. 32. Disadvantages of Yii framework It is written in approach that does not support the most innovative, modern advantages brought to PHP development world with release of PHP 5.3 and soon – PHP version 6. Differences are so big that Yii developers decided that to fulfil PHP 5.3/6.0 needs the entire framework had to be rewritten from scratch. Due to complexity of this task, it is not scheduled to be achieved earlier than at the beginning of 2012
  33. 33. Conclusion Yii does not need to be installed under a Web-accessible directory. An Yii application has one entry script which is usually the only file that needs to be exposed to Web users. Other PHP scripts, including those from Yii, should be protected from Web access since they may be exploited for hacking.
  34. 34. References   [1] www.code.google.com/yii/ [2] Wikipedia – Yii [3] http://www.yiiframework.com
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×