PHP code example of bingcool / swoolefy

1. Go to this page and download the library: Download bingcool/swoolefy library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bingcool / swoolefy example snippets

   
当前终端启动:php swoolefy start monitor config.php   
守护进程启动:php swoolefy start monitor config.php -d         
停止:php swoolefy stop monitor 9502     

当前终端启动:php swoolefy start monitor websocket9503.php   
守护进程启动:php swoolefy start monitor websocket9503.php -d         
停止:php swoolefy stop monitor 9503
     
启动:php swoolefy start http  
守护进程启动:php swoolefy start http -d            
停止:php swoolefy stop http 
    
启动:php swoolefy start websocket 
守护进程启动:php swoolefy start websocket -d            
停止:php swoolefy stop websocket      
    
启动:php swoolefy start rpc     
守护进程启动:php swoolefy start rpc -d        
停止:php swoolefy stop rpc
    
启动:php swoolefy start udp    
守护进程启动:php swoolefy start udp -d     
停止:php swoolefy stop udp


namespace App\Controller;

use Swoolefy\Core\Application;
use Swoolefy\Core\Controller\BController;

class IndexController extends BController {

    public function index() {
        $this->response->end('hello word!');
    }

}


namespace App\Controller;

use Swoolefy\Core\Application;
use Swoolefy\Core\Controller\BController;

class IndexController extends BController {

    public function index() {
        $this->assign('name','hello word!');
        $this->display('index.html');

}

location / {
            proxy_http_version 1.1;
            proxy_set_header Connection "keep-alive";
            proxy_set_header X-Real-IP $remote_addr;
            proxy_pass http://127.0.0.1:9502;
        }