Introduction to the Yii PHP5 Framework
Yii is an excellent, open source, user friendly PHP application framework with a rich set of features built-in from the start, making website application development a breeze. If you're doing web application development and aren't yet using a framework, I'd highly recommend Yii.
Released for use on the BSD License, the Yii framework is built for PHP5 with performance, security and rapid deployment in mind. The framework is the brainchild of Qiang Xue, who previously developed and maintained the Prado PHP framework.
For those not familiar with the concept of what application frameworks are, they normally define the structure of an application (i.e. where files go, naming conventions, etc.), an architectural pattern (i.e. MVC) and provide a collection of programming libraries / classes.
Following the Model, Controller, View (MVC) application architecture, the development process will be familiar to anyone that has dealt with the likes of CakePHP, CodeIgniter, Symfony, Zend, etc. However, for those who have not come across this architecture before, a brief overview follows.
MVC is considered an application design pattern. It is a way of breaking down an application into three domains.
- Model - used for handling data requests to and from the likes of databases, files, networks, etc. Data validation is also handled in this area of the application.
- View - this is presentation code that normally interacts with the end user of the application (e.g. HTML / PHP output)
- Controller - performs the logic work within the application.
Typically, an MVC application flows in a manner such that a Controller sends or retrieves data from Models, the Controller in question then works on the data and then passes the resulting information to a View for display / rendering to the end user.
Using Yii's great application deployment tool and the Gii user interface you can have an application up and running in a matter of minutes.
The first thing you will need to do in order to get started is download the Yii framework from www.yiiframework.com. Then extract the framework archive to a computer that you have access to the command line on.
To create a new application you simply perform the following from the command line:
$ cd YiiPath/framework
$ ./yiic webapp ../appName
yiic webapp ..\appName
'YiiPath' is the path to the location on your disk drive where you extracted the Yii framework to and 'appName' is the name of the application you wish to create.
If you don't have access to the command line on your web server (i.e. you are using shared web hosting), you can run the above commands on your local computer and later upload the resulting application files to you web hosting account. However, please be aware that you will also need PHP installed on the local computer if you wish to first create the application locally.
Your new application will be created in 'YiiPath/appName'.