CodeIgniter框架中尝试使用swoole

时间:2023-01-20 15:43:29

  ci框架版本:3.1.7、     swoole版本:1.7、      php版本:5.6

  相关文档:

  以cli方式运行ci框架

  swoole官方手册

  创建一个TestSwoole和Hello控制器

<?php
defined('BASEPATH') OR exit('No direct script access allowed'); class TestSwoole extends CI_Controller{
public function index(){
$process = new swoole_process(function(swoole_process $worker){
$worker->exec("/usr/bin/php",array("index.php","hello","index"));
});
$process->start();
}
public function repeatDoing(){
swoole_timer_tick(1000,function(){
$this->index();
});
}
}
?>

  

<?php
defined('BASEPATH') OR exit('No direct script access allowed'); class Hello extends CI_Controller {
public function index(){
echo "hello\n";
}
}

  

  然后在命令行中,进入到ci框架的根目录,执行以下命令:

[root@localhost ci]# php index.php TestSwoole repeatDoing

  

相关文章