SlideShare a Scribd company logo
By Shahzad Malik (cadet018@gmail.com)
yii?
IS it fast? ...
IS it secure? ...
IS it professional? ...
IS it right for my next project?
Yes It Is!
Topics
• Introduction to Yii
– Workflow (MVC)
– Installation Steps
• Features
• Some Code Samples
– Model
– Using Model from Controller
– Controller
– View
Topics
• Performance
Introduction to Yii & performance comparison with Drupal
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/
Introduction – Workflow (MVC)
Introduction - Installation
Introduction - Installation
http://www.yiiframework.com/download
Introduction - Installation
Extract framework folder to any directory with access rights
Introduction - Installation
Extract requirements folder to a web-accessible
directory http://www.example.com/requirements
Requirements
Introduction - Installation
Open console (Command Prompt) and run following command from
web-accessible directory
/path/to/php.exe /path/to/framework/yiic.php webapp myfirstyiiapp
Introduction - Installation
That’s it
Introduction – Installation - Summary
Extract framework folder
Check requirements
Run install command from console
Download
Introduction – Installation - Preview
Introduction to Yii & performance comparison with Drupal
Features
Features
• Skinning and theming
You 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.
Features
• Automatic code generation
Yii 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 testing
Test-Driven Development - using PHPUnit and
Selenium Remote Control
Features
• Authentication and authorization
Yii has built-in authentication support. It also
supports authorization via hierarchical role-
based access control.
• Layered caching scheme
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.
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)
Introduction to Yii & performance comparison with Drupal
Model
class 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,
));
}
}
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
Controller
class 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,
));
}
}
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',
),
)); ?>
Introduction to Yii & performance comparison with Drupal
Performance
Performance – Lazy loading example
/**
* @return array relational rules.
*/
public function relations()
{
return array(
'userRole' => array(self::BELONGS_TO, 'TblRole', 'user_role_id'),
);
}
TblUserModal
Schema
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>
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>
Performance – Drupal & Yii
Performance – Drupal & Yii
Performance – Drupal & Yii

More Related Content

What's hot (8)

PPTX
Php iis microsoft
Nick Hodge
 
PDF
CBDW2014 - ColdBox 4 Modules
Ortus Solutions, Corp
 
PPTX
Cake php development
Helios Solutions
 
PPTX
OpenIDM - An Introduction
ForgeRock
 
PDF
Extending the WSO2 Governance Registry with Handlers and Filters
WSO2
 
PPTX
FHIR Server internals - sqlonfhir
Brian Postlethwaite
 
ODP
Cakephp
Ly Channa
 
PPTX
OpenIDM: An Introduction
ForgeRock
 
Php iis microsoft
Nick Hodge
 
CBDW2014 - ColdBox 4 Modules
Ortus Solutions, Corp
 
Cake php development
Helios Solutions
 
OpenIDM - An Introduction
ForgeRock
 
Extending the WSO2 Governance Registry with Handlers and Filters
WSO2
 
FHIR Server internals - sqlonfhir
Brian Postlethwaite
 
Cakephp
Ly Channa
 
OpenIDM: An Introduction
ForgeRock
 

Similar to Introduction to Yii & performance comparison with Drupal (20)

PDF
Introduce Yii
zakieh alizadeh
 
PPTX
Yii framework
Leena Roja
 
PDF
Folio3 - An Introduction to PHP Yii
Folio3 Software
 
PPT
Yii php framework_honey
Honeyson Joseph
 
PPTX
P H P Framework
Animesh Kumar
 
PPSX
Yii framework
Mohammed Saqib
 
PPTX
yii1
Rajat Gupta
 
PPTX
Yii2
Rajat Gupta
 
ZIP
Fwdtechseminars
Prânith Kumâr
 
PPT
Yii workshop
Simone Gentili
 
PDF
Get things done with Yii - quickly build webapplications
Giuliano Iacobelli
 
KEY
Yii Framework
Jason Ragsdale
 
PPTX
yii framework
Akhil Kumar
 
KEY
Yii Introduction
Jason Ragsdale
 
PPT
10 reasons to choose the yii framework
jananya213
 
PPT
Introduction to YII framework
Naincy Gupta
 
PPTX
Yii Training session-1
AkkiCredencys
 
PDF
Yii vs codeigneiter
Luis Alberto Rodriguez
 
PDF
Web Application Development with Yii and PHP 2nd Revised ed. Edition Jeffrey ...
yttrdhlsud173
 
Introduce Yii
zakieh alizadeh
 
Yii framework
Leena Roja
 
Folio3 - An Introduction to PHP Yii
Folio3 Software
 
Yii php framework_honey
Honeyson Joseph
 
P H P Framework
Animesh Kumar
 
Yii framework
Mohammed Saqib
 
Fwdtechseminars
Prânith Kumâr
 
Yii workshop
Simone Gentili
 
Get things done with Yii - quickly build webapplications
Giuliano Iacobelli
 
Yii Framework
Jason Ragsdale
 
yii framework
Akhil Kumar
 
Yii Introduction
Jason Ragsdale
 
10 reasons to choose the yii framework
jananya213
 
Introduction to YII framework
Naincy Gupta
 
Yii Training session-1
AkkiCredencys
 
Yii vs codeigneiter
Luis Alberto Rodriguez
 
Web Application Development with Yii and PHP 2nd Revised ed. Edition Jeffrey ...
yttrdhlsud173
 
Ad

Recently uploaded (20)

PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Ad

Introduction to Yii & performance comparison with Drupal

  • 3. IS it fast? ... IS it secure? ... IS it professional? ... IS it right for my next project?
  • 5. Topics • Introduction to Yii – Workflow (MVC) – Installation Steps • Features • Some Code Samples – Model – Using Model from Controller – Controller – View
  • 8. 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/
  • 12. Introduction - Installation Extract framework folder to any directory with access rights
  • 13. Introduction - Installation Extract requirements folder to a web-accessible directory http://www.example.com/requirements
  • 15. Introduction - Installation Open console (Command Prompt) and run following command from web-accessible directory /path/to/php.exe /path/to/framework/yiic.php webapp myfirstyiiapp
  • 17. Introduction – Installation - Summary Extract framework folder Check requirements Run install command from console Download
  • 21. Features • Skinning and theming You 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.
  • 22. Features • Automatic code generation Yii 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 testing Test-Driven Development - using PHPUnit and Selenium Remote Control
  • 23. Features • Authentication and authorization Yii has built-in authentication support. It also supports authorization via hierarchical role- based access control. • Layered caching scheme 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.
  • 24. 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)
  • 26. Model class 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, )); } }
  • 27. 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
  • 28. Controller class 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, )); } }
  • 29. 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', ), )); ?>
  • 32. Performance – Lazy loading example /** * @return array relational rules. */ public function relations() { return array( 'userRole' => array(self::BELONGS_TO, 'TblRole', 'user_role_id'), ); } TblUserModal Schema
  • 33. 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>
  • 34. 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>

Editor's Notes

  • #10: 1. A user makes a request with the URL http://www.example.com/index.php?r=post/show&amp;id=1 and the Web server handles the request by executing the bootstrap script index.php.2. The bootstrap script creates an Application instance and runs it.3. The Application obtains detailed user request information from an application component named request.4. The application determines the requested controller and action with the help of an application component named urlManager. 5. The application creates an instance of the requested controller to further handle the user request. (e.g. action name is show) The controller determines that the action refers to a method named actionShow in the controller class. It then creates and executes filters (e.g. access control, benchmarking) associated with this action. The action is executed if it is allowed by the filters.6. The action reads the data from model class based on criteria defined in controller and model class.7. The action renders a view with the model object.8. The view reads and displays the attributes of the model.9. The view executes some widgets.10. The view rendering result is embedded in a layout.11. The action completes the view rendering and displays the result to the user.
  • #32: Yii is so much faster because it is using the lazy loading technique extensively. For example, it does not include a class file until the class is used for the first time; and it does not create an object until the object is accessed for the first time. Other frameworks suffer from the performance hit because they would enable a functionality (e.g. DB connection, user session) no matter it is used or not during a request.