Yii学习笔记

1、运行环境检测,Yii提供了检测工具

  /requirements/index.php

2、使用yiic生成应用程序

  切换到framework目录下,执行yiic webapp ../<项目名称>  

下面的树图描述了我们这个应用的目录结构。请查看约定以获取该结构的详细解释。



testdrive/

   index.php                 Web 应用入口脚本文件

   index-test.php            功能测试使用的入口脚本文件

   assets/                   包含公开的资源文件

   css/                      包含 CSS 文件

   images/                   包含图片文件

   themes/                   包含应用主题

   protected/                包含受保护的应用文件

      yiic                   yiic 命令行脚本

      yiic.bat               Windows 下的 yiic 命令行脚本

      yiic.php               yiic 命令行 PHP 脚本

      commands/              包含自定义的 'yiic' 命令

         shell/              包含自定义的 'yiic shell' 命令

      components/            包含可重用的用户组件

         Controller.php      所有控制器类的基础类

         Identity.php        用来认证的 'Identity' 类

      config/                包含配置文件

         console.php         控制台应用配置

         main.php            Web 应用配置

         test.php            功能测试使用的配置

      controllers/           包含控制器的类文件

         SiteController.php  默认控制器的类文件

      data/                  包含示例数据库

         schema.mysql.sql    示例 MySQL 数据库

         schema.sqlite.sql   示例 SQLite 数据库

         testdrive.db        示例 SQLite 数据库文件

      extensions/            包含第三方扩展

      messages/              包含翻译过的消息

      models/                包含模型的类文件

         LoginForm.php       'login' 动作的表单模型

         ContactForm.php     'contact' 动作的表单模型

      runtime/               包含临时生成的文件

      tests/                 包含测试脚本

      views/                 包含控制器的视图和布局文件

         layouts/            包含布局视图文件

            main.php         所有视图的默认布局

            column1.php      使用单列页面使用的布局

            column2.php      使用双列的页面使用的布局

         site/               包含 'site' 控制器的视图文件

            pages/           包含 "静态" 页面

               about.php     "about" 页面的视图

            contact.php      'contact' 动作的视图

            error.php        'error' 动作的视图(显示外部错误)

            index.php        'index' 动作的视图

            login.php        'login' 动作的视图

         system/             包含系统视图文件
目录结构

 3、使用gii首先需要编辑文件 WebRoot/testdrive/protected/main.php

 

除非你使用127.0.0.1访问,否则IpFilters一定要配置。不然会出现“You are not allowed to access this page.

'gii'=>array(

            'class'=>'system.gii.GiiModule',

            'password'=>'michaelzx',

            // If removed, Gii defaults to localhost only. Edit carefully to taste.

            'ipFilters'=>array('192.168.231.4','::80'),

        ),
View Code

4、

你可能感兴趣的:(学习笔记)