Difference between #2 and #3 of
Run Yiic directly from your app without a shell

Revision #3 has been created by jacmoe on Aug 27, 2011, 2:34:56 AM with the memo:

Cleaned up code
« previous (#2)

Changes

Title unchanged

Run Yiic directly from your app without a shell

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

yiic, console, cli, command, shell

Content changed

[...]
### Run yiic migrate in an action
#### Code

```php
private function runMigrationTool() {
     $commandPath = Yii::app()->getBasePath() . DIRECTORY_SEPARATOR . 'commands';      $runner = new CConsoleCommandRunner();     $runner->addCommands($commandPath);      $commandPath = Yii::getFrameworkPath() . DIRECTORY_SEPARATOR . 'cli' . DIRECTORY_SEPARATOR . 'commands';     $runner->addCommands($commandPath);      $args = array('command', 'yiic', 'migrate', '--interactive=0');         $command = $runner->createCommand($args[0]);
 
        array_shift($args);
 
    
ob_start();      $runner->run($args);      echo htmlentities(ob_get_clean(), null, Yii::app()->charset);     }
```
#### How to use
You can call it from a controller action like this:

```php
[...]
13 0
20 followers
Viewed: 48 833 times
Version: 1.1
Category: How-tos
Written by: jacmoe
Last updated by: jacmoe
Created on: Aug 27, 2011
Last updated: 12 years ago
Update Article

Revisions

View all history