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 ?
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'),