Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions frameworks/workerman/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
FROM ubuntu:24.04
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
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

Expand Down
2 changes: 1 addition & 1 deletion frameworks/workerman/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"workerman/workerman": "dev-master"
"workerman/workerman": "^v5.2.2"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 1 addition & 0 deletions frameworks/workerman/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"json",
"json-tls",
"static",
"static-tls",
"api-4",
"api-16",
"async-db",
Expand Down
12 changes: 10 additions & 2 deletions frameworks/workerman/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@
$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));
}

//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);
}

Expand Down Expand Up @@ -106,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 = [];
Expand All @@ -120,6 +122,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'],
Expand Down
Loading