php - how to call background function from web controller in yii2 -
i have controller function save file in db , create personal pdf file every record in db , email him . problem take time. can call console controller web controller function , pass id console function? or there better or other method this?
i don't think calling console command web controller much.
but purpose can use example this extension.
usage:
imported class:
use vova07\console\consolerunner; $cr = new consolerunner(['file' => '@my/path/to/yii']); $cr->run('controller/action param1 param2 ...');
application component:
// config.php ... components [ 'consolerunner' => [ 'class' => 'vova07\console\consolerunner', 'file' => '@my/path/to/yii' // or absolute path console file ] ] ... // some-file.php yii::$app->consolerunner->run('controller/action param1 param2 ...');
but recommend use work queues rabbitmq or beanstalkd, these more suitable task.
Comments
Post a Comment