CodeIgniter框架中尝试使用swoole
ci框架版本:3.1.7、 swoole版本:1.7、 php版本:5.6
相关文档:
创建一个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
如需转载,请注明文章出处,谢谢!!!