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