yii framework 初始



开始用yii framework,帮助初始化,帮助我们构建整个的平台
1  php YiiRoot/framework/yiic.php webapp testdrive

 1 $yii=dirname(__FILE__).'/framework/yii.php';
 2 $config=dirname(__FILE__).'/store/protected/config/main.php';
 3 
 4 // remove the following lines when in production mode
 5 defined('YII_DEBUG') or define('YII_DEBUG',true);
 6 // specify how many levels of call stack should be shown in each log message
 7 defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
 8 
 9 require_once($yii);
10 
11 Yii::createWebApplication($config)->run();

最忌比较懒,不喜欢写很多东西,这可怎么办呢,

1,他的controller,里面的方法和zend写的正好相反,

yii actionIndex() //index方法
zend indexAction()//index方法

2,没有设置之前都是在Views文件夹下面对应的控制器文件夹下有一个一样名字的模板文件,不同的是

yii  后缀 php
zend 后缀tpl

3,配置文件

 1 return array(
 2     'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
 3     'name'=>'xiaoshaoye',
 4     
 5     'defaultController'=>'index',
 6     // preloading 'log' component
 7     'preload'=>array('log'),
 8 
 9     // autoloading model and component classes
10     'import'=>array(
11         'application.models.*',
12         'application.components.*',
13     ),
14     
15     'modules'=>array(
16         // uncomment the following to enable the Gii tool
17         /*
18         'gii'=>array(
19             'class'=>'system.gii.GiiModule',
20             'password'=>'Enter Your Password Here',
21             // If removed, Gii defaults to localhost only. Edit carefully to taste.
22             'ipFilters'=>array('127.0.0.1','::1'),
23         ),
24         */
25     ),
26 
27     // application components
28     'components'=>array(
29         'user'=>array(
30             // enable cookie-based authentication
31             'allowAutoLogin'=>true,
32         ),
33         // uncomment the following to enable URLs in path-format
34         
35         'db'=>array(
36             'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
37         ),
38         // uncomment the following to use a MySQL database
39         
40         'db'=>array(
41             'connectionString' => 'mysql:host=localhost;dbname=app_xiaoshaoye',
42             'emulatePrepare' => true,
43             'username' => 'root',
44             'password' => '',
45             'charset' => 'utf8',
46         ),
47         'urlManager'=>array(
48             'urlFormat'=>'path',
49             'rules'=>array(
50                 '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
51             ),
52         ),
53 
54         'errorHandler'=>array(
55             // use 'index/error' action to display errors
56             'errorAction'=>'index/error',
57         ),
58         'log'=>array(
59             'class'=>'CLogRouter',
60             'routes'=>array(
61                 array(
62                     'class'=>'CFileLogRoute',
63                     'levels'=>'error, warning',
64                 ),
65                 // uncomment the following to show log messages on web pages
66                 
67                 array(
68                     'class'=>'CWebLogRoute',
69                     'levels'=>'error, warning',
70                 ),
71                 
72             ),
73         ),
74 
75     ),
76 
77     // application-level parameters that can be accessed
78     // using Yii::app()->params['paramName']
79     'params'=>array(
80         // this is used in contact page
81         'adminEmail'=>'webmaster@example.com',
82     ),
83 );
config.php

配置文件每一个是什么,自己去试吧

4,http://www.yiichina.com/guide/quickstart.first-app 送一个网址

原文地址:https://www.cnblogs.com/zhangjun516/p/3123560.html