PHP Yii open-source framework (1)

Source: Internet
Author: User

The following content is written for the Yii Framework training for members. 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, install the missing software if it does not comply with the requirements. If it is displayed that php pdo is not successful, check php. check whether the ini configuration item is consistent with that in 1.9. 4) to facilitate viewing the example program in the Yii framework, add the sqlite database support in the php configuration file and restart Apache to take effect: extension = php_pdo_sqlite.dll5) 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/frameworkD: \ var \ w Ww \ 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 allows you 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 method of the template website, and modify test1/protected/config/main. php is as follows:/* 'db' => array ('ononstring' => 'sqlite :'. dirname (_ FILE __). '/.. /data/testdrive. db',), * // uncomment the following Use a MySQL database 'db' => array ('ononstring' => 'mysql: host = 127.0.0.1; dbname = test1', 'emulateprepare' => 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, delete, query, modify): Edit protected/config/main. php is 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, select generate model, input table name: test1_userinfo, Model class name: TUserInfo; click Generate, the Model class will be generated in: test1 \ protected \ models select to generate CRUD in the same way. The code is generated in: test1 \ protected \ controllerstest1 \ protected \ views \ tUserInfo to study test1 \ protected \ controllers \ TUserInfoController. php and other generated web pages enter the web site to access the generated web page: http: // 127.0.0.1/test1/index. php? R = tuserinfo add module: Open webpage: http: // 127.0.0.1/index. php? R = gii enter the password, select generate module, enter UserInfo module name, and click Generate. The webpage is generated in: test1 \ protected \ modules \ UserInfo to edit main. php is as follows: 'modules' => array (// uncomment the following to enable the Gii tool 'gii' => array ('class' => 'System. gii. giiModule ', 'Password' => 'nokialab', // If removed, Gii defaults to localhost only. edit carefully to taste. 'ipfilters '=> array ('123. 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 to Eclipse: Make sure that the eclipse version is helios for php and the. project file is created under the project root directory. The content is: <? Xml version = "1.0" encoding = "UTF-8"?> <ProjectDescription> <name> webprojectname </name> <comment> </comment> <projects> </projects> <buildSpec> <buildCommand> <name> org. eclipse. wst. validation. validationbuilder </name> <arguments> </buildCommand> <name> org. eclipse. dltk. core. scriptbuilder </name> <arguments> </buildCommand> </buildSpec> <natures> <nature> org. eclipse. php. core. PHPNature </nature> </natures> </pro JectDescription> Create the. buildpath file in the root directory of the project. The content is: <? Xml version = "1.0" encoding = "UTF-8"?> <Buildpath> www.2cto.com <buildpathentry external = "true" kind = "lib" path = "D:/var/www/html/yii"/> </buildpath> 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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.