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

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM