Difference between #1 and #2 of
How to extend yiic shell commands

Revision #2 has been created by wei on Oct 26, 2010, 3:08:03 AM with the memo:

formatting, tags
« previous (#1)

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
[...]
2 0
5 followers
Viewed: 26 100 times
Version: 1.1
Category: Tutorials
Tags: yiic
Written by: qiang
Last updated by: wei
Created on: Jul 21, 2009
Last updated: 7 years ago
Update Article

Revisions

View all history