introduction to yii & performance comparison with drupal
DESCRIPTION
This is simple introduction to yii & how to install it on WAMP. Plus some performance comparison with Drupal.TRANSCRIPT
![Page 1: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/1.jpg)
By Shahzad Malik ([email protected])
![Page 2: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/2.jpg)
yii?
![Page 3: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/3.jpg)
IS it fast? ...
IS it secure? ...
IS it professional? ...
IS it right for my next project?
![Page 4: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/4.jpg)
Yes It Is!
![Page 5: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/5.jpg)
Topics
• Introduction to Yii– Workflow (MVC)– Installation Steps
• Features• Some Code Samples
– Model– Using Model from Controller– Controller– View
![Page 6: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/6.jpg)
Topics
• Performance
![Page 7: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/7.jpg)
Introduction
![Page 8: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/8.jpg)
Introduction
Yii is a free, open-source Web application development framework written in PHP5 that promotes clean, DRY design and encourages rapid development. It works to streamline your application development and helps to ensure an extremely efficient, extensible, and maintainable end product.Source: http://www.yiiframework.com/about/
![Page 9: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/9.jpg)
Introduction – Workflow (MVC)
![Page 10: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/10.jpg)
Introduction - Installation
5STEPS
![Page 11: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/11.jpg)
Introduction - Installation
STEP 1
http://www.yiiframework.com/download
![Page 12: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/12.jpg)
Introduction - Installation
STEP 2
Extract framework folder to any directory with access rights
![Page 13: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/13.jpg)
Introduction - Installation
STEP 3Extract requirements folder to a web-accessible directory http://www.example.com/requirements
![Page 14: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/14.jpg)
Requirements
![Page 15: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/15.jpg)
Introduction - Installation
STEP 4
Open console (Command Prompt) and run following command from web-accessible directory/path/to/php.exe /path/to/framework/yiic.php webapp myfirstyiiapp
![Page 16: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/16.jpg)
Introduction - Installation
STEP 5 That’s it
![Page 17: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/17.jpg)
Introduction – Installation - Summary
Extract framework folderSTEP 2
Check requirementsSTEP 3
Run install command from consoleSTEP 4
DownloadSTEP 1
![Page 18: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/18.jpg)
Introduction – Installation - Preview
![Page 19: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/19.jpg)
Features
![Page 20: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/20.jpg)
Features
![Page 21: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/21.jpg)
Features
• Skinning and themingYou can select theme at project level, controller level, action level Or based on some condition in action.
• Error handling and logging Errors are handled and presented more nicely, and log messages can be categorized, filtered and routed to different destinations.
![Page 22: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/22.jpg)
Features
• Automatic code generationYii provides a set of spontaneous and highly extensible code generation tools that can help you quickly generate the code you need for features such as form input, CRUD.
• Unit and functionality testingTest-Driven Development - using PHPUnit and Selenium Remote Control
![Page 23: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/23.jpg)
Features
• Authentication and authorizationYii has built-in authentication support. It also supports authorization via hierarchical role-based access control.
• Layered caching schemeYii supports data caching, page caching, fragment caching and dynamic content. The storage medium of caching can be changed easily without touching the application code.
![Page 24: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/24.jpg)
Features - Extensions
Auth (42)Caching (22)Console (17)Database (100)Date and Time (24)Error Handling (4)File System (29)Logging (26)Mail (16)Networking (21)Security (15)User Interface (475)Validation (65)Web Service (77)Others (289)
![Page 25: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/25.jpg)
Some code samples
![Page 26: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/26.jpg)
Modelclass Post extends CActiveRecord{ /** * Retrieves a list of models based on the current search/filter conditions. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. */ public function search() { $criteria=new CDbCriteria;
$criteria->compare('content ',$this->content ); $criteria->compare('title ',$this->title ,true); return new CActiveDataProvider($this, array( 'criteria'=>$criteria, )); }}
![Page 27: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/27.jpg)
Model From Controller
Create$post = new Post;$post->title = 'sample post';$post->content = 'post body content';$post->save(); <- This is validated
Select$post=Post::model()->find(array( 'select'=>'title', 'condition'=>'postID=:postID', 'params'=>array(':postID'=>2),));
Update$post = Post::model()->findByPk(2);$post->title = ‘New title’;$post->save(); <- This is validated
![Page 28: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/28.jpg)
Controllerclass PostController extends Controller { /** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionView($id) { $post = Post::model()->findByPk($id); if(!$post) throw new CHttpException(404); $this->render('view', array( 'post' => $post, )); }}
![Page 29: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/29.jpg)
View$this->breadcrumbs=array( 'Posts'=>array('index'), $post>title, ); ?>
<h1>View Post #<?php echo $post>id; ?></h1>
<?php $this->widget('zii.widgets.CDetailView', array( 'data'=>$post, 'attributes'=>array( 'title', 'content', ), )); ?>
![Page 30: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/30.jpg)
Performance
![Page 31: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/31.jpg)
Performance
![Page 32: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/32.jpg)
Performance – Lazy loading example
/** * @return array relational rules. */ public function relations() { return array( 'userRole' => array(self::BELONGS_TO, 'TblRole', 'user_role_id'), ); }TblU
ser M
odal
Sche
ma
![Page 33: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/33.jpg)
Performance – Lazy loading example
<table> <tr><th>User id</th><td><?php echo $user->id; ?></td></tr> <tr><th>User name</th><td><?php echo $user->username; ?></td></tr> <tr><th>Role</th><td><?php echo $user->user_role_id; ?></td></tr></table>
![Page 34: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/34.jpg)
Performance – Lazy loading example
<table> <tr><th>User id</th><td><?php echo $user->id; ?></td></tr> <tr><th>User name</th><td><?php echo $user->username; ?></td></tr> <tr><th>Role</th><td><?php echo $user->userRole->role_name; ?></td></tr></table>
![Page 35: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/35.jpg)
Performance – Drupal & Yii
![Page 36: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/36.jpg)
Performance – Drupal & Yii
![Page 37: Introduction to Yii & performance comparison with Drupal](https://reader033.vdocuments.net/reader033/viewer/2022061122/54701b3aaf7959551c8b456f/html5/thumbnails/37.jpg)
Performance – Drupal & Yii