walkor / workerman

An asynchronous event driven PHP socket framework. Supports HTTP, Websocket, SSL and other custom protocols.

Home Page:http://www.workerman.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What the best way to use workerman with yii2?

shizzic opened this issue · comments

Just share your implemination please. I think it may be a big help for many ppl.

I have an implementation with Adapterman.

image

I can help you and show the code.

PD: I think that I read somewhere, than exist an implementation only for yii2.

I have an implementation with Adapterman.

image

I can help you and show the code.

PD: I think that I read somewhere, than exist an implementation only for yii2.

Please, share your code)

The code in the benchmark:
https://github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/PHP/yii2

The important parts:
server.php
https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/frameworks/PHP/yii2/server.php

Added the 2 lines:

 $_SERVER['SCRIPT_FILENAME'] = '/app/index.php';
 $_SERVER['SCRIPT_NAME'] = '/index.php';

As yii2, don't created it correctly.

The WorkerTimer is because the bench need to have a Date: header.
And I didn't want to touch the initial yii2 app code.

index.php
https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/frameworks/PHP/yii2/app/index.php#L54-L62
image

To run with Workerman, you only need to comment the line 54.

Dockefile
https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/frameworks/PHP/yii2/yii2-workerman.dockerfile
image

Here I need to change 1 line in yii2, or stop there always (marked with the arrow)
And run it php server.php start.

Remember that Adapterman is only an application server, you need to serve static files with the webserver.

Thank you!