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
";
    }
}

  

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

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

  

原文地址:https://www.cnblogs.com/-beyond/p/8692768.html