yii使用yiic shell创建控制器

发表于:2017-11-06 19:29 阅读:

切换到项目目录,如demo,执行protected\yiic shell,效果如下:
D:\xampp\htdocs\demo>protected\yiic shell
Yii Interactive Tool v1.1 (based on Yii v1.1.13)
Please type 'help' for help. Type 'exit' to quit.
>>
 
创建控制器说明:
>> help controller
USAGE
  controller <controller-ID> [action-ID] ...
 
DESCRIPTION
  This command generates a controller and views associated with
  the specified actions.
 
PARAMETERS
 * controller-ID: required, controller ID, e.g., 'post'.
   If the controller should be located under a subdirectory,
   please specify the controller ID as 'path/to/ControllerID',
   e.g., 'admin/user'.
 
   If the controller belongs to a module, please specify
   the controller ID as 'ModuleID/ControllerID' or
   'ModuleID/path/to/Controller' (assuming the controller is
   under a subdirectory of that module).
 
 * action-ID: optional, action ID. You may supply one or several
   action IDs. A default 'index' action will always be generated.
 
EXAMPLES
 * Generates the 'post' controller:
        controller post
 
 * Generates the 'post' controller with additional actions 'contact'
   and 'about':
        controller post contact about
 
 * Generates the 'post' controller which should be located under
   the 'admin' subdirectory of the base controller path:
        controller admin/post
 
 * Generates the 'post' controller which should belong to
   the 'admin' module:
        controller admin/post
 
NOTE: in the last two examples, the commands are the same, but
the generated controller file is located under different directories.
Yii is able to detect whether 'admin' refers to a module or a subdirectory.
 
创建一个名为post的控制器:
>> controller post
   generate PostController.php
      mkdir D:/xampp/htdocs/demo/protected/views/post
   generate index.php
 
Controller 'post' has been created in the following file:
    D:\xampp\htdocs\demo\protected\controllers\PostController.php
 
You may access it in the browser using the following URL:
    http://hostname/path/to/index.php?r=post


灵石网络专注于营销型网站设计、SEO搜索引擎优化、PHP开发、企业网络营销服务。


扫描二维码加我微信!