Yii console application action as web application action

create an action


class NotifyUnsharedItemsAction extends CAction
    public function run()
        echo "ok";

then in controller action is loaded as usuall:

class TestController extends Controller

    public function actions() {
        return array(

and in command i run action in such way:

class NotifyUnsharedItemsCommand extends CConsoleCommand
    public function run($args)
        $action = Yii::createComponent('application.controllers.actions.NotifyUnsharedItemsAction',$this,'notify');

more details here

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s