Top Banner
Musa Talukdar Software Engineer 9 th feb,2012
24

yii PHP Framework

Oct 15, 2014

Download

Documents

Musa Talukdar

Musa Talukdar
Software Engineer
9th feb,2012

About Yii
‡ free, open-source Web application development framework written in PHP5 ‡ brainchild of its founder, Qiang Xue ‡ You have full control over the configuration from head-to-toe ‡ Fast, secure, professional

Credits
‡ Prado: Yii adopts its component-based and eventdriven programming paradigm, database abstraction layers, modular application architecture, internationalization and localization, and many of its other features and patterns. ‡
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: yii PHP Framework

Musa TalukdarSoftware Engineer

9th feb,2012

Page 2: yii PHP Framework

About Yii

• free, open-source Web application development framework written in PHP5

• brainchild of its founder, Qiang Xue• You have full control over the configuration

from head-to-toe• Fast, secure, professional

Page 3: yii PHP Framework

Credits• Prado: Yii adopts its component-based and event-driven

programming paradigm, database abstraction layers, modular application architecture, internationalization and localization, and many of its other features and patterns.

• Ruby on Rails: Yii referenced its implementation of the active record design pattern for its ORM layer.

• jQuery: This is integrated in Yii as the foundational JavaScript framework.

• Symfony: Yii referenced its filter design and plug-in architecture.

• Joomla: Yii referenced its modular design and message translation scheme.

Page 4: yii PHP Framework

Features

• MVC• Database Access Object• Form validation• Authentication and authorization• Skinning and theming• Web service• i18N and L10n• Layered cashing scheme…

Page 5: yii PHP Framework

…Features

• Error handling and logging• Security• Unit and functional testing• Automatic code generation• Friendly with third-party code• Detailed documentation• Extension library

Page 6: yii PHP Framework

MVC

Page 7: yii PHP Framework

Database Access Objects (DAO), Query Builder, Active Record, DB Migration

• Data Access Object(DAO) Build on top of PHP Data Object enables accessing to different database

management systems (DBMS) in a single uniform interface.

easily switched to use a different DBMS without the need to modify the data accessing code

Page 8: yii PHP Framework

Database Access Objects (DAO), Query Builder, Active Record, DB Migration

• Yii Query Builder object-oriented method for building queries helps reduce risk of SQL injection attacks

• Yii Active Record(AR) implemented as a widely adopted Object-

Relational Mapping (ORM) approachRepresenting a table in terms of a class and a row

an instanceeliminates the repetitive task of writing those SQL

statements that mainly deal with CRUD (create, read, update and delete) operations.

Page 9: yii PHP Framework

…example of an AR insert

CREATE TABLE tbl_post (

id INTEGER NOT NULL PRIMARY KEY

AUTOINCREMENT,

title VARCHAR(128) NOT NULL,

content TEXT NOT NULL,

create_time INTEGER NOT NULL );

$post=new Post;

$post->title='sample post';

$post->content='post body content';

$post->save();

Page 10: yii PHP Framework

Form input and validation

• form helper to create form using php• Form validation using ajax• display appropriate error messages for invalid

input

Page 11: yii PHP Framework

Authentication and authorization

• built-in authentication support• authorization via hierarchical role-based

access control (RBAC).

Page 12: yii PHP Framework

Skinning and theming

• Yii implements a skinning and theming mechanism that allows you to quickly switch the outlook of a Yii-power website.

• While using a theme we can quickly change the outlook of views, we can use skins to systematically customize the outlook of the widgets used in the views.

Page 13: yii PHP Framework

Internationalization (I18N) and localization (L10N)

• locale data for each possible language and variant.

• message and file translation service• locale-dependent date and time formatting.• locale-dependent number formatting.

Page 14: yii PHP Framework

Layered caching scheme

• Yii supports Data caching Query CachingPage cachingFragment caching Dynamic content caching

• The storage medium of caching can be changed easily without touching the application code.

Page 15: yii PHP Framework

Layered caching scheme

CMemCache: uses PHP memcache extension.CApcCache: uses PHP APC extension.CXCache: uses PHP XCache extension.CEAcceleratorCache : uses PHP EAccelerator extension .CDbCache: uses a database table to store cached data. By default, it

will create and use a SQLite3 database under the runtime directory. You can explicitly specify a database for it to use by setting its connectionID property.

CZendDataCache: uses Zend DataCache as the underlying caching medium.

CFileCache : uses files to store cached data. This is particular suitable to cache large chunk of data (such as pages).

Page 16: yii PHP Framework

Security

• Cross-site Scripting Prevention using HTML Purifire

• Cross-site Request Forgery PreventionCHtml::form method will embed the necessary random

value in a hidden field so that it can be submitted for CSRF validation

• Cookie Attack Prevention Yii implements a cookie validation scheme that prevents

cookies from being modified.

Page 17: yii PHP Framework

Testing

• unit and functional testing• The testing supported provided by Yii requires

PHPUnit and Selenium Remote Control• The most basic unit is function• Functional test on module• Create the required file structure for testing

Page 18: yii PHP Framework

Automatic code generation

• 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.

Page 19: yii PHP Framework

And many more…

• Module• Component• Web service• Extension library

Page 20: yii PHP Framework
Page 21: yii PHP Framework

let's get our hands dirty

Page 22: yii PHP Framework

…let's get our hands dirty

1. Install Yii2. Create database3. Generate model and CRUD4. Customize your code …done

Page 23: yii PHP Framework
Page 24: yii PHP Framework

Refercnce

• http://www.yiiframework.com/• http://en.wikipedia.org/wiki/Yii• http://www.phpframeworks.com• Yii 1.1 Application Development Cookbook