Swoole 4.0 official version, PHP collaboration engine for production environment

  coroutine, golang, php, swoole

SwooleAlthough in2016The synergetic feature was supported in, but since the bottom layer is based onsetjmp/longjmpRealizedstacklessPlan. Therefore, in some scenarios, such ascall_user_funcarray_map__destructConcorde cannot be used in. Logic in large applications is very complex, and developers are easy to step into pits in teams with many people working together. Use Synergy in Forbidden ScenesAPIThere will be various puzzling problems. The application range of synergetic process is limited.

new edition4.0Based onboost.context 1.60The assembly code realizes a brand-new synergetic kernel. SavingPHPOn the basis of the function call stack, theCContext storage of stack. It has realized the right to allPHPGrammatical support. Now in anyPHPFunctions of, includingcall_user_funcReflectance, magic methods,array_mapConcorde can be used in both.

It is now available atPHPConcorde is used anywhere in the code, developers no longer need to worry about usage scenarios.4.0Version We andSwooleDistributed/Swoft/EasySwooleThe authors of the framework have worked closely together and conducted gray scale trials in a large number of projects. Stability and robustness have reached the industrial level. It can be used in the production environment of large-scale projects.

go(function() {
 array_map("test", array("func start\n"));
 echo "co end\n";
 function test($p) {
 echo $p;
 echo "func end \n";

4.0The branch is usedC++11Standard, recommendedgcc-4.8Or later.

Global variable isolation

In the new version, the bottom layer has isolated global variables and can now be usedSwoole\ProcessCreate multipleSwoole\ServerAn example is given.

for ($i = 0;   $i < 2;  $i++)
 $p = new swoole_process(function () use ($i) {
 $port = 9501 + $i;
 $http = new swoole_http_server("", $port);
 $http->on("start", function ($server) use ($port) {
 echo "Swoole http server is started at{$port}\n";
 $http->on("request", function ($request, $response) {
 $response->header("Content-Type", "text/plain");
 $response->end("Hello World\n");
 }, false, false);

Other updates

  • Repairhttp2The server was unable toChromeBrowser client sent more than16KData problems
  • RepairBASEIn modeTaskThe process cannot be restarted
  • IncreaseChannel->peekMethod for peeking at data
  • RepairServer->pause/resumeInSWOOLE_PROCESSCan’t use under the problem
  • removeLinux AIO, asynchronous files are now implemented using thread pools regardless of settings.IO
  • SupportMySQLStored procedure

Download 4.0