Yii文档生成器不接受docs命令

Yii文档生成器不接受docs命令

问题描述:

I want to use Yii document generator, i have extracted the source in protected/commands.

When I try to run the command:

yiic docs check

it says:

Yii command runner (based on Yii v1.1.8)
Usage: c:\wamp\www\FRAMEW~1\yiic <command-name> [parameters...]

The following commands are available:
 - message
 - migrate
 - shell
 - webapp

To see individual command help, use the following:
   c:\wamp\www\FRAMEW~1\yiic help <command-name>

Do I need to edit any config to run docs command ?

我想使用Yii文档生成器,我已经在protected / commands中提取了源代码。 p>

当我尝试运行命令时: p>

  yiic docs check 
  code>  pre> 
 
 

它说: p>

  Yii命令运行器(基于Yii v1.1.8)
使用:c:\ wamp \ www \ FRAMEW~1 \ yiic&lt; command-name&gt;  [参数...] 
 
以下命令可用:
  -  message 
  -  migrate 
  -  shell 
  -  webapp 
 
要查看单个命令帮助,请使用以下命令:
c:\ wamp \  www \ FRAMEW~1 \ yiic help&lt; command-name&gt; 
  code>  pre> 
 
 

我是否需要编辑任何配置才能运行 docs code>命令? p> div>

You can add a Command to your CConsoleApplication by adding it to the commandMap. add this to your protected/config/console.php:

'commandMap' => array(
     'docs' => array(
        // alias of the path where you extracted the DocsCommand.php
        'class' => 'application.commands.DocsCommand',
      )
),

after that yiic docs will run DocsCommand and it also should appear in the list of available commands.

You have to do this in your console application config since CWebapplication and CConsoleApplication have many different properties you can set via config. commandMap in this example is a property of CConsoleApplication but not of CWebApplication so you can only define it in console app. Read more about configuration in Yii's Definitive Guide

Also if you have a look at the yiic.php in your applications protected path you will see it includes the console.php file:

<?php

// change the following paths if necessary
$yiic=dirname(__FILE__).'/../yii/framework/yiic.php';
$config=dirname(__FILE__).'/config/console.php';

require_once($yiic);

If you have configuration that should be the same for web and console, for example a database connection, you can put that into an own config file e.g. config/db.php and include it in both config/main.php and config/console.php like this:

'db' => include(dirname(__FILE__). '/db.php'),