From 0448a16032ba1f9d2fd88f693494b85cf1130d31 Mon Sep 17 00:00:00 2001 From: Joan Miquel Date: Fri, 14 Aug 2026 18:38:51 +0200 Subject: [PATCH 1/7] Update Workerman and add more tests --- frameworks/workerman/composer.json | 2 +- frameworks/workerman/meta.json | 2 ++ frameworks/workerman/server.php | 28 +++++++++++++++++++++++++--- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/frameworks/workerman/composer.json b/frameworks/workerman/composer.json index d0c8ca7e6..6729d5065 100644 --- a/frameworks/workerman/composer.json +++ b/frameworks/workerman/composer.json @@ -1,6 +1,6 @@ { "require": { - "workerman/workerman": "dev-master" + "workerman/workerman": "^v5.2.2" }, "autoload": { "psr-4": { diff --git a/frameworks/workerman/meta.json b/frameworks/workerman/meta.json index 15bc3456e..c02b02fc6 100644 --- a/frameworks/workerman/meta.json +++ b/frameworks/workerman/meta.json @@ -12,8 +12,10 @@ "pipelined", "limited-conn", "json", + "json-comp", "json-tls", "static", + "static-tls", "api-4", "api-16", "async-db", diff --git a/frameworks/workerman/server.php b/frameworks/workerman/server.php index 6722573d9..ba84b9a2e 100644 --- a/frameworks/workerman/server.php +++ b/frameworks/workerman/server.php @@ -68,13 +68,29 @@ $item['total'] = $item['price'] * $item['quantity'] * $m; $total[] = $item; } - $connection->headers = ['Content-Type' => 'application/json']; - return $connection->send(json_encode(['items' => $total, 'count' => $count], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); + + $result = json_encode(['items' => $total, 'count' => $count], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + $header = []; + if($encoding = $request->header('accept-encoding', '')) { + if(str_contains($encoding, 'br')) { + $result = brotli_compress($result, 1); + $header = ['Content-Encoding' => 'br']; + } elseif (str_contains($encoding, 'gzip')) { + $result = gzencode($result, 1); + $header = ['Content-Encoding' => 'gzip']; + } + } + + return new Response ( + 200, + ['Content-Type' => 'application/json'] + $header, + $result + ); } //Serve static files if (str_starts_with($path, '/static/')) { - $response = (new Response())->withFile('/data' . $path); + $response = new Response()->withFile('/data' . $path); return $connection->send($response); } @@ -120,6 +136,12 @@ return $connection->send(json_encode(['items' => $total, 'count' => $count], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); } + //Serve static files + if (str_starts_with($path, '/static/')) { + $response = new Response()->withFile('/data' . $path); + return $connection->send($response); + } + return $connection->send(new Response( 404, ['Content-Type' => 'text/plain'], From d8a2a97dc28481aafa28cee5a86b1a954a9fc2a3 Mon Sep 17 00:00:00 2001 From: Joan Miquel Date: Fri, 14 Aug 2026 18:44:21 +0200 Subject: [PATCH 2/7] Use Ubutntu 26.04 --- frameworks/workerman/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/workerman/Dockerfile b/frameworks/workerman/Dockerfile index 2c1d0ad55..4e54bbb98 100644 --- a/frameworks/workerman/Dockerfile +++ b/frameworks/workerman/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.04 +FROM ubuntu:26.04 ARG DEBIAN_FRONTEND=noninteractive From 9cf72a1d8d0c764bdd52424b50383e318326c4e8 Mon Sep 17 00:00:00 2001 From: Joan Miquel Date: Fri, 14 Aug 2026 18:47:48 +0200 Subject: [PATCH 3/7] Remove ondrej packages --- frameworks/workerman/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frameworks/workerman/Dockerfile b/frameworks/workerman/Dockerfile index 4e54bbb98..83b83dc7b 100644 --- a/frameworks/workerman/Dockerfile +++ b/frameworks/workerman/Dockerfile @@ -3,8 +3,7 @@ FROM ubuntu:26.04 ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update -yqq && apt-get install -yqq software-properties-common > /dev/null -RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php > /dev/null && \ - apt-get update -yqq > /dev/null && apt-get upgrade -yqq > /dev/null +RUN apt-get update -yqq > /dev/null && apt-get upgrade -yqq > /dev/null RUN apt-get install -yqq php8.5-cli php8.5-xml php8.5-zip php8.5-pgsql> /dev/null From a716f24d0e3938ad9c1f0dffe1dbb05fe7dffab4 Mon Sep 17 00:00:00 2001 From: Joan Miquel Date: Fri, 14 Aug 2026 19:23:28 +0200 Subject: [PATCH 4/7] Add zip and unzip libs --- frameworks/workerman/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/workerman/Dockerfile b/frameworks/workerman/Dockerfile index 83b83dc7b..604d69225 100644 --- a/frameworks/workerman/Dockerfile +++ b/frameworks/workerman/Dockerfile @@ -5,7 +5,7 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update -yqq && apt-get install -yqq software-properties-common > /dev/null RUN apt-get update -yqq > /dev/null && apt-get upgrade -yqq > /dev/null -RUN apt-get install -yqq php8.5-cli php8.5-xml php8.5-zip php8.5-pgsql> /dev/null +RUN apt-get install -yqq zip unzip php8.5-cli php8.5-xml php8.5-zip php8.5-pgsql php8.5-zip> /dev/null COPY --from=composer/composer:latest-bin --link /composer /usr/local/bin/composer From e54b70ea6d7eaaf2eca5fd3b2eadb1c316554109 Mon Sep 17 00:00:00 2001 From: Joan Miquel Date: Fri, 14 Aug 2026 19:30:10 +0200 Subject: [PATCH 5/7] Remove duplicated lib --- frameworks/workerman/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/workerman/Dockerfile b/frameworks/workerman/Dockerfile index 604d69225..54b388d59 100644 --- a/frameworks/workerman/Dockerfile +++ b/frameworks/workerman/Dockerfile @@ -5,7 +5,7 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update -yqq && apt-get install -yqq software-properties-common > /dev/null RUN apt-get update -yqq > /dev/null && apt-get upgrade -yqq > /dev/null -RUN apt-get install -yqq zip unzip php8.5-cli php8.5-xml php8.5-zip php8.5-pgsql php8.5-zip> /dev/null +RUN apt-get install -yqq zip unzip php8.5-cli php8.5-xml php8.5-zip php8.5-pgsql> /dev/null COPY --from=composer/composer:latest-bin --link /composer /usr/local/bin/composer From 5145aacc65802f8a903cb1b5184aa87fe06913f6 Mon Sep 17 00:00:00 2001 From: Joan Miquel Date: Fri, 14 Aug 2026 20:07:04 +0200 Subject: [PATCH 6/7] Remove json-comp --- frameworks/workerman/meta.json | 1 - frameworks/workerman/server.php | 19 ++----------------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/frameworks/workerman/meta.json b/frameworks/workerman/meta.json index c02b02fc6..4936ce938 100644 --- a/frameworks/workerman/meta.json +++ b/frameworks/workerman/meta.json @@ -12,7 +12,6 @@ "pipelined", "limited-conn", "json", - "json-comp", "json-tls", "static", "static-tls", diff --git a/frameworks/workerman/server.php b/frameworks/workerman/server.php index ba84b9a2e..51d441730 100644 --- a/frameworks/workerman/server.php +++ b/frameworks/workerman/server.php @@ -69,23 +69,8 @@ $total[] = $item; } - $result = json_encode(['items' => $total, 'count' => $count], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); - $header = []; - if($encoding = $request->header('accept-encoding', '')) { - if(str_contains($encoding, 'br')) { - $result = brotli_compress($result, 1); - $header = ['Content-Encoding' => 'br']; - } elseif (str_contains($encoding, 'gzip')) { - $result = gzencode($result, 1); - $header = ['Content-Encoding' => 'gzip']; - } - } - - return new Response ( - 200, - ['Content-Type' => 'application/json'] + $header, - $result - ); + $connection->headers = ['Content-Type' => 'application/json']; + return $connection->send(json_encode(['items' => $total, 'count' => $count], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); } //Serve static files From b1737c61c86b164655066490d030951c5a81bd99 Mon Sep 17 00:00:00 2001 From: Joan Miquel Date: Fri, 14 Aug 2026 20:24:33 +0200 Subject: [PATCH 7/7] Fix typo --- frameworks/workerman/server.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frameworks/workerman/server.php b/frameworks/workerman/server.php index 51d441730..1dc0e9015 100644 --- a/frameworks/workerman/server.php +++ b/frameworks/workerman/server.php @@ -107,7 +107,8 @@ $https->onMessage = static function ($connection, $request) { - if(str_starts_with($request->path(), '/json/')) { + $path = $request->path(); + if(str_starts_with($path, '/json/')) { $count = explode('/', $request->path())[2]; $m = $request->get('m', 1); $total = [];