PHPYii open-source framework (1 ). The following content is written for the Yii Framework training for members. 1) Download Yii1.1.12: 2) decompress the package to varwwwhtml and rename the directory to yii. 3) Check whether the computer environment meets the yii requirements. The following are some content written for the Yii Framework training for members.
1) Download Yii 1.1.12:
2) decompress the package to/var/www/html and rename the directory to yii;
3) Check whether the computer environment meets the yii requirements. if the computer environment does not comply with the requirements, install the required software. if the php pdo is not successfully displayed, check whether the php. ini configuration item is consistent with that in 1.9;
4) to facilitate viewing the example program in the Yii Framework, you can add the sqlite database support in the php configuration file and restart Apache to take effect:
Extension = php_pdo_sqlite.dll
5) open the program and website that comes with Yii and study its structure and program:
Http: // 127.0.0.1/yii/demos/helloworld/
Http: // 127.0.0.1/yii/demos/blog/
And so on.
6) use the Yii tool to generate a template website:
Open the command line tool: Start-> Run. the command is as follows:
C: \ Users \ bihhe> d:
D: \> cd/var/www/html/yii/framework
D: \ var \ www \ html \ yii \ framework>/var/php53/php/var/www/html/yii/framework/yiic. php webapp/var/www/html/test1
Open the browser and enter http: // 127.0.0.1/test1/index. php to access the created website.
7) create a database table:
Create table 'test1'. 'test1 _ userinfo '(
'Id' integer unsigned not null AUTO_INCREMENT,
'Uname' VARCHAR (45) not null,
'Upass' VARCHAR (45) not null,
'Count' integer unsigned,
Primary key ('id ')
)
ENGINE = InnoDB;
8) modify the database connection mode of the template website, and modify test1/protected/config/main. php as follows:
/*
'DB' => array (
'Connectionstring' => 'sqlite: '. dirname (_ FILE _).'/../data/testdrive. db ',
),
*/
// Uncomment the following to use a MySQL database
'DB' => array (
'Connectionstring' => 'MySQL: host = 127.0.0.1; dbname = test1 ',
'Default' => true,
'Username' => 'root ',
'Password' => 'password ',
'Charset' => 'utf8 ',
'Tableprefix' => 'test1 _',
),
After configuration, we can use Yii: app ()-> db to call the database connection anywhere.
9) use the Gii tool to generate Model and CRUD (add, query, modify, and delete ):
Edit protected/config/main. php as follows:
Return array (
......
'Import' => array (
'Application. models .*',
'Application. components .*',
),
'Modules' => array (
'Giii '=> array (
'Class' => 'system. gii. GiiModule ',
'Password' => 'pick up a password here ',
),
),
);
Open the webpage: http: // 127.0.0.1/index. php? R = gii
Enter the password and select generate model. input table name: test10000userinfo and Model class name: TUserInfo;
Click Generate. The Model class is generated in: test1 \ protected \ models.
In the same way, select generate CRUD. the code is generated in:
Test1 \ protected \ controllers
Test1 \ protected \ views \ tUserInfo
Study test1 \ protected \ controllers \ TUserInfoController. php and other generated web pages
Enter the URL to access the generated webpage: http: // 127.0.0.1/test1/index. php? R = tuserinfo
Add module: Open the webpage: http: // 127.0.0.1/index. php? R = gii
Enter the password, select generate module, enter the UserInfo module name, and Click Generate. The webpage is generated:
Test1 \ protected \ modules \ UserInfo
Edit main. php as follows:
'Modules' => array (
// Uncomment the following to enable the Gii tool
'Giii '=> array (
'Class' => 'system. gii. GiiModule ',
'Password' => 'nokialab ',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'Ipfilters '=> array ('127. 0.0.1', ': 1 '),
),
'Userinfo ',
),
Enter the URL http: // 127.0.0.1/test1/index. php? R = UserInfo/default/index to access the newly generated module.
10) import a project in Eclipse: make sure that the eclipse version is helios for php.
Create a. project file in the project root directory with the following content:
Webprojectname
Org. eclipse. wst. validation. validationbuilder
Org. eclipse. dltk. core. scriptbuilder
Org. eclipse. php. core. PHPNature
Create the. buildpath file in the root directory of the project. the content is as follows:
Www.2cto.com
Open eclipse, File à Import à Existing Project into Workspace à Next à Select root directory, Select the Project directory, and continue.
11) if the Yii page includes view and layout has Chinese characters, change the format of saving the page to UTF-8; otherwise, Chinese characters will be garbled;
Bytes. 1) Download Yii 1.1.12: 2) decompress it to/var/www/html and rename the directory to yii; 3) Check whether the computer environment meets yii requirements...