YII-giiで簡単なyiiプロジェクトをすばやく作成!

6980 ワード

yiiは、関連するコンポーネントとアプリケーションを迅速に作成するための強力なコマンドラインツールを提供します.以下では、yicツールでyiiアプリケーションをすばやく作成する私のwebディレクトリをd:wwwでyiframework D:wwwyiiframework winプラットフォームcdからwwwyiiframeworkディレクトリにアクセスしてcmdコマンドを実行する方法について説明します.

C:\Users******>d:
*【 D 】

D:>cd www\yii\framework

D:\www\yii\framework>yiic webapp../testapp/

* testapp framework 【 】
Create a Web application under 'D:\www\yii\testapp'? [Yes|No]y

*【 y/yes 】
mkdir D:/www/yii/testapp
mkdir D:/www/yii/testapp/assets
mkdir D:/www/yii/testapp/css
generate css/bg.gif
generatecss/form.css
generate css/ie.css
generatecss/main.css
generatecss/print.css
generatecss/screen.css
mkdir D:/www/yii/testapp/images
generateindex-test.php
generate index.php
mkdir D:/www/yii/testapp/protected
generateprotected/.htaccess
mkdir D:/www/yii/testapp/protected/commands
mkdir D:/www/yii/testapp/protected/commands/shell
mkdir D:/www/yii/testapp/protected/components
generateprotected/components/Controller.php
generateprotected/components/UserIdentity.php
mkdir D:/www/yii/testapp/protected/config
generateprotected/config/console.php
generateprotected/config/main.php
generateprotected/config/test.php
mkdir D:/www/yii/testapp/protected/controllers
generateprotected/controllers/SiteController.php
mkdir D:/www/yii/testapp/protected/data
generateprotected/data/schema.mysql.sql
generateprotected/data/schema.sqlite.sql
generateprotected/data/testdrive.db
mkdir D:/www/yii/testapp/protected/extensions
mkdir D:/www/yii/testapp/protected/messages
mkdir D:/www/yii/testapp/protected/migrations
mkdir D:/www/yii/testapp/protected/models
generateprotected/models/ContactForm.php
generateprotected/models/LoginForm.php
mkdir D:/www/yii/testapp/protected/runtime
mkdir D:/www/yii/testapp/protected/tests
generateprotected/tests/bootstrap.php
mkdir D:/www/yii/testapp/protected/tests/fixtures
mkdir D:/www/yii/testapp/protected/tests/functional
generateprotected/tests/functional/SiteTest.php
generateprotected/tests/phpunit.xml
mkdir D:/www/yii/testapp/protected/tests/report
mkdir D:/www/yii/testapp/protected/tests/unit
generateprotected/tests/WebTestCase.php
mkdir D:/www/yii/testapp/protected/views
mkdir D:/www/yii/testapp/protected/views/layouts
generateprotected/views/layouts/column1.php
generateprotected/views/layouts/column2.php
generateprotected/views/layouts/main.php
mkdir D:/www/yii/testapp/protected/views/site
generateprotected/views/site/contact.php
generateprotected/views/site/error.php
generateprotected/views/site/index.php
generateprotected/views/site/login.php
mkdir D:/www/yii/testapp/protected/views/site/pages
generateprotected/views/site/pages/about.php
generateprotected/yiic
generateprotected/yiic.bat
generateprotected/yiic.php
mkdir D:/www/yii/testapp/themes
mkdir D:/www/yii/testapp/themes/classic
mkdir D:/www/yii/testapp/themes/classic/views
generatethemes/classic/views/.htaccess
mkdir D:/www/yii/testapp/themes/classic/views/layouts
mkdir D:/www/yii/testapp/themes/classic/views/site
mkdir D:/www/yii/testapp/themes/classic/views/system

Your application has been created successfullyunder

ok    yii         

 win+wamp              :
![image.png](http://upload-images.jianshu.io/upload_images/2255249-045f697168f430b2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

   yiic webapp   ,       : ‘"php.exe"’         ,               。

   yiic        php.exe    
   、  yiic.bat  
  yii    d:/www/yii/framework/yiic.bat,yiic.bat           :

  
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
 
    WAMP      php.exe   Windows     ,  yiic   。       php.exe       PHP_COMMAND  。             :

  
if "%PHP_COMMAND%" == "" setPHP_COMMAND=D:\wamp\php\php.exe 
 
   、 php yii framework       

       ->   
 ![image.png](http://upload-images.jianshu.io/upload_images/2255249-f26bace3a994420a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

![image.png](http://upload-images.jianshu.io/upload_images/2255249-93257473e993d374.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

![image.png](http://upload-images.jianshu.io/upload_images/2255249-9cb7127270e240c2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

![image.png](http://upload-images.jianshu.io/upload_images/2255249-d006652d874ea4c5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)









  

  

*      php.exe      。




ok yiic        !~
gii   :
  config      gii  ,    。     ,    ,    ,    。      gii  ,Model Generator   * ,                    。
       model    Crud Generator   controller view    。
       table prefix    model  ,     。    ,   model class       ,         。table name        ,         。
![Paste_Image.png](http://upload-images.jianshu.io/upload_images/2255249-96c957bc4d2b37b5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Modules    demo:  APP,  protected     modeules/APP   。
     , gii  ,   main.php    modules      :



 
'modules'=>array(
    // uncomment the following to enable the Gii tool
     

 
    'gii'=>array(
        'class'=>'system.gii.GiiModule',
        'password'=>'a',
        // If removed, Gii defaults to localhost only. Edit carefully to taste.
        'ipFilters'=>array('127.0.0.1','::1'),
    ),
    'Home'=>array(
        'class'=>'application.modules.Home.HomeModule',
    ),
     
    'Admin'=>array(
        'class'=>'application.modules.Admin.AdminModule',
    ),
     
    'App'=>array(
        'class'=>'application.modules.App.AppModule',
    ),
     
),
![Paste_Image.png](http://upload-images.jianshu.io/upload_images/2255249-b87fe13354bf9c67.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

![Paste_Image.png](http://upload-images.jianshu.io/upload_images/2255249-b2401797c5193a05.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
         protected/modules 。model    。curd   ,model class       , controller id    module  。

![Paste_Image.png](http://upload-images.jianshu.io/upload_images/2255249-0fb2e777e86ea2aa.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
           (         public $layout='//layouts/column2'; column2  column1),
      (protected\views\layouts\column1.php)