Anda di halaman 1dari 21

Yii FRAMEWORK INSTALLATION & CREATE WEB APPLICATION

Download Yii Framework from http://www.yiiframework.com/download/ and Unpack the Yii release file to a Web-accessible directory(C: wamp www in this e!ample" and then rename yii.

#pen yo$r web browser and open http://%&'.(.(.%/yii/re)$irements/ and make s$re there is no tro$ble with the re)$irements.

*ow open yo$r command prompt. Chan+e the directory to yo$r Yii framework folder $sin+ ,cd- command (cd C: wamp www".

.o b$ild a new webapp na/i+ate to the pro0ect root directory type ,yii framework yiic webapp testapp-. Finally type ,yes- for confirmation.

*ow yo$ can open the web application from web browser http://%&'.(.(.%/testapp/.

#pen $p protected confi+ main.php and Uncomment the lines pertainn+ to the +ii mod$le:
1+ii123array( 1class1231system.+ii.4ii5od$le16 1password1231password16 // 7f remo/ed6 4ii defa$lts to localhost only. 8dit caref$lly to taste. 1ipFilters123array(1%&'.(.(.%161::%1"6 "6

*ow yo$ can open the web application from web browser: http://%&'.(.(.%/testapp/inde!.php9r2+ii

.hen yo$ ha/e enter the password: password for open the Yii Code 4enerator.

Yii code 4enerators

Controller 4enerator: .his +enerator helps yo$ to )$ickly +enerate a new controller class6 one or se/eral controller actions and their correspondin+ /iews. Cr$d 4enerator: .his +enerator +enerates a controller and /iews that implement C:UD operations for the specified data model. Form 4enerator: .his +enerator +enerates a /iew script file that displays a form to collect inp$t for the specified model class. 5odel 4enerator: .his +enerator +enerates a model class for the specified database table. 5od$le 4enerator: .his +enerator helps yo$ to +enerate the skeleton code needed by a Yii mod$le.

Confi+$re o$r application to $se a database. Create a new database6 called Db;User and Create a new table in the database called tbl;User.

4o to php5y<dmin from web browser: http://%&'.(.(.%/phpmyadmin/.

.he followin+ fi+$re shows yo$r =>=5y<dmin interface6 0$st enter yo$r database name and click the 1Create1 b$tton to create yo$r database.

*ow to create a new table enter yo$r tablename and the n$mber of fields in the table6 then click the 14o1 ?$tton.

.he ne!t step is to create the fields6 0$st enter /al$es for each field name6 type6 len+th of the field6 n$ll option and mention whether it is a primary key or not. .hen click the 1@a/e1 b$tton to complete yo$r table creation.

#pen $p testapp protected confi+ main.php and add 1db1 application component.

Comment the followin+ to $se a 5y@AB database 1db123array( 1connection@trin+1 23 1s)lite:1.dirname(;;F7B8;;".1/../data/testdri/e.db16 "6

Uncomment the followin+ to $se a 5y@AB database and Chan+e the db name 1db123array(

1connection@trin+1 23 1mys)l:host2localhostCdbname2Db;User16 1em$late=repare1 23 tr$e6 1$sername1 23 1root16 1password1 23 116 1charset1 23 1$tfD16 "6

4eneratin+ the User 5odel: <fter lo+in6 click on the link 5odel 4enerator. .his will brin+ $s to the followin+ model +eneration pa+e6

4eneratin+ C:UD Code: <fter creatin+ the model class file6 we will +enerate the code that implements the C:UD operations abo$t the $ser data.

*ow yo$ can open the web application from web browser: http://%&'.(.(.%/testapp/inde!.php9r2$ser

We lo+in as an administrator $sin+ admin/admin6 we can /iew the $ser admin pa+e

We can click on the buttons on each row of data to view, update or delete the corresponding row of data.

We can click on the b$ttons on each row of data to /iew6 $pdate or delete the correspondin+ row of data.

Anda mungkin juga menyukai