CodeIgniter框架中尝试使用swoole

  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

  

posted @ 2018-04-02 13:58  寻觅beyond  阅读(2642)  评论(0编辑  收藏  举报
返回顶部