YII FRAMEWORK
1) Yii is a high-performance PHP framework best for developing Web
applications.
2)The latest version of Yii 2 is 2.0.9, released on July 11, 2016.The first version
was 1.1
Why YII?
1) Easy to Install
2)CRUD generator
3) Security(ACF & RBAC)
4) Yii is open-source, and it’s free.
5)Extensions. Yii's community offers a variety of free, open source plugins and widgets
6)Internationalization
7)Lazy Loading
Why so fast?
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
Installation Process
There are two ways to install Yii (Basic and advance):
1)Install via Composer
2)Install from an Archive File
Features of YII-
MVC-
Model-the model represents the information (the data) and the business rules
View- the view contains elements of the user interface such as text, form inputs
Controller- controller manages the communication between the model and the
view.
Pattern
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.
The application determines the requested controller and action with the help of
an application component named urlManager.
In the above example when the above url will run,following scenario will be
followed-
1)The url manager will called the controller named post
2)The method which is defined in that controller will be called i.e show
3)The third ids the parameter which we are passing i.e id
In the above method if the method name is not passed .Ex-
http://www.example.com/index.php?r=post
Then in that case the default method will be called i.e. index
To change default method-
public $defaultAction = 'test';
2)Support Multiple dbms
Yii Data Access Objects (DAO) enables accessing to different database
management systems (DBMS) in a single uniform interface. Applications
developed using Yii DAO can be easily switched to use a different DBMS
without the need to modify the data accessing code.
Ex-SQLite, MySQL, PostgreSQL, MSSQL or Oracle
/common/config/main-local.php you set your database settings:
/*$sql="select * from db.tablename";
$sql1="select * from db2.";
$result = Yii::$app->db->createCommand($sql)->queryAll();//db connection 1
$result = Yii::$app->db2->createCommand($sql1)->queryAll();//db connection
2
*/
Similary we can use multiple
/*$sql="select * from db.tablename";
$sql1="select * from db2.";
$result = Yii::$app->db->createCommand($sql)->queryAll();//db connection 1
$result = Yii::$app->db2->createCommand($sql1)->queryAll();//db connection
2
*/
Similary we can use multiple
Automatic Code Generation
GII-
Yii is equipped with a Web-based code generation tool called Gii
All the basic operations CRUD can be generated very easily
Automatic Code Generation
GII-
Yii is equipped with a Web-based code generation tool called Gii
All the basic operations CRUD can be generated very easily
Model Generator
Model Validation
public function rules()
{
return [
[['name', 'address'], 'required'],
[['name', 'address'], 'string', 'max' => 100]
];
}
Useful links
1)http://www.yiiframework.com/download/
2)http://www.yiiframework.com/doc-2.0/guide-index.html
3)http://www.freetuts.org/tutorial/yii2-framework
4)https://github.com/yiisoft/yii2-app-advanced
yii1

yii1

  • 1.
    YII FRAMEWORK 1) Yiiis a high-performance PHP framework best for developing Web applications. 2)The latest version of Yii 2 is 2.0.9, released on July 11, 2016.The first version was 1.1
  • 2.
    Why YII? 1) Easyto Install 2)CRUD generator 3) Security(ACF & RBAC) 4) Yii is open-source, and it’s free. 5)Extensions. Yii's community offers a variety of free, open source plugins and widgets 6)Internationalization 7)Lazy Loading
  • 4.
    Why so fast? Yiiis 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
  • 5.
    Installation Process There aretwo ways to install Yii (Basic and advance): 1)Install via Composer 2)Install from an Archive File
  • 6.
    Features of YII- MVC- Model-themodel represents the information (the data) and the business rules View- the view contains elements of the user interface such as text, form inputs Controller- controller manages the communication between the model and the view.
  • 7.
    Pattern A user makesa 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. The application determines the requested controller and action with the help of an application component named urlManager.
  • 8.
    In the aboveexample when the above url will run,following scenario will be followed- 1)The url manager will called the controller named post 2)The method which is defined in that controller will be called i.e show 3)The third ids the parameter which we are passing i.e id
  • 9.
    In the abovemethod if the method name is not passed .Ex- http://www.example.com/index.php?r=post Then in that case the default method will be called i.e. index To change default method- public $defaultAction = 'test';
  • 10.
    2)Support Multiple dbms YiiData Access Objects (DAO) enables accessing to different database management systems (DBMS) in a single uniform interface. Applications developed using Yii DAO can be easily switched to use a different DBMS without the need to modify the data accessing code. Ex-SQLite, MySQL, PostgreSQL, MSSQL or Oracle /common/config/main-local.php you set your database settings:
  • 12.
    /*$sql="select * fromdb.tablename"; $sql1="select * from db2."; $result = Yii::$app->db->createCommand($sql)->queryAll();//db connection 1 $result = Yii::$app->db2->createCommand($sql1)->queryAll();//db connection 2 */ Similary we can use multiple
  • 13.
    /*$sql="select * fromdb.tablename"; $sql1="select * from db2."; $result = Yii::$app->db->createCommand($sql)->queryAll();//db connection 1 $result = Yii::$app->db2->createCommand($sql1)->queryAll();//db connection 2 */ Similary we can use multiple
  • 14.
    Automatic Code Generation GII- Yiiis equipped with a Web-based code generation tool called Gii All the basic operations CRUD can be generated very easily
  • 15.
    Automatic Code Generation GII- Yiiis equipped with a Web-based code generation tool called Gii All the basic operations CRUD can be generated very easily
  • 17.
  • 20.
    Model Validation public functionrules() { return [ [['name', 'address'], 'required'], [['name', 'address'], 'string', 'max' => 100] ]; }
  • 21.