PHP code example of swoole-foundation / yii2-swoole-extension

1. Go to this page and download the library: Download swoole-foundation/yii2-swoole-extension 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/ */

    

swoole-foundation / yii2-swoole-extension example snippets


	// config/server.php
	
	  return [
	   'host' => 'localhost',
	   'port' => 9501,
	   'mode' => SWOOLE_PROCESS,
	   'sockType' => SWOOLE_SOCK_TCP,
	   'app' =>   'task_worker_num' => 2,
	   ]
	];
	

	// config/swoole.php
	
	
	$config = ss'] = swoole\foundation\web\Response::class;
	$config['components']['request']['class'] = swoole\foundation\web\Request::class;
	$config['components']['errorHandler']['class'] = swoole\foundation\web\ErrorHandler::class;
	
	return $config;
	

  // bootstrap.php
  
  /**
   * @author xialeistudio
   * @date 2019-05-17
   */
  
  use swoole\foundation\web\Server;
  use Swoole\Runtime;
  
  // Warning: singleton in coroutine environment is untested!
  Runtime::enableCoroutine();
  defined('YII_DEBUG') or define('YII_DEBUG', true);
  defined('YII_ENV') or define('YII_ENV', getenv('PHP_ENV') === 'development' ? 'dev' : 'prod');
  
  
bash
  php bootstrap.php