Changes
Title
unchanged
How to extend yiic shell commands
Category
unchanged
Tutorials
Yii version
unchanged
Tags
changed
yiic
Content
changed
[...]
While `yiic shell` tool is very convenient at generating skeleton code in our application, the generated code is not always what we want. For example, we may want the generated code to carry specific copyright information; we may want to use our own coding style; we may want to add more features; and so on. All these can be accomplished easily in Yii.
In the following, we explain how to extend the `model` and `crud` commands, which are the two most powerful `yiic shell` commands.
## Extending `model` Command
When we create our initial application code using `yiic webapp` command, we may find there is a directory called `protected/commands/shell`. This is the place where we shall store the extended shell command classes.[...]
We should be able to use our newly created model command now. Enter the `yiic shell` and type `help`. We should see a list of available shell commands which now include a new command called `mymodel`. Try using this command the same way as using the original `model` command (e.g. `mymodel Post`). We should see that the generated model class is using the template we just wrote.
## Extending `crud` Command
Extending the `crud` command is only a bit more complex than extending the `model` command. We create a file named `protected/commands/shell/MycrudCommand.php` as follows,
```php[...]