We will start with the basic setup of the Yii environment; that is, connecting to a database server and automated generation of Gii and forms with Yii.
This book assumes that you are familiar with the PHP development environment and have a basic development environment set up for PHP application development.
Download the Yii framework from http://www.yiiframework.com/ and extract its framework folder outside your Public_html
folder or web root folder. Your application will refer to Yii Bootstrap, Yii.php
, located inside the Framework
folder.
Let's move to creating the web application. We will use the command-line utility of Yii to generate the new Yii application.
Open the command prompt or a console under Linux.
Change the current folder to where the framework has been extracted and enter the following command:
yii> framework/yiic webapp webRoot/sampleapp
Access the newly generated application at
http://localhost/sampleapp/index.php
.
The command will ask you for confirmation and will then generate the basic structure of the Yii application. You can find the details of the directory structure at http://www.yiiframework.com/wiki/155/the-directory-structure-of-the-yii-project-site/.
Yii has already created a few simple pages with a Contact Us form and a Login form. Following is the screenshot of the default Contact Us form: