Browse Source

Workerman disable php7.4 (#6223)

* [workerman] Delete php 7.4 version

* Use match() instead of switch()
New in php8

* Fix dockerfile to use mysql

* Update workerman pgsql to php8
Joan Miquel 4 years ago
parent
commit
d7ec76dd6c

+ 34 - 34
frameworks/PHP/workerman/app.php

@@ -21,40 +21,32 @@ function init()
 
 function router(Request $request)
 {
-    switch ($request->path()) {
-        case '/plaintext':
-            return new Response(200, [
-                'Content-Type' => 'text/plain',
-                'Date'         => Header::$date
-            ], 'Hello, World!');
-
-        case '/json':
-            return new Response(200, [
-                'Content-Type' => 'application/json',
-                'Date'         => Header::$date
-            ], json_encode(['message' => 'Hello, World!']));
-
-        case '/db':
-            return db();
-
-        case '/fortunes':
-            // By default use 'Content-Type: text/html; charset=utf-8';
-            return fortune();
-
-        case '/query':
-            return query($request);
-
-        case '/update':
-            return updateraw($request);
-
-/*        case '/info':
-            ob_start();
-            phpinfo();
-            return new Response(200, ['Content-Type' => 'text/plain'], ob_get_clean());
- */
-        default:
-            return new Response(404, [], 'Error 404');
-    }
+    return match($request->path()) {
+        '/plaintext' => text(),
+        '/json'      => json(), 
+        '/db'        => db(),
+        '/fortunes'  => fortune(),
+        '/query'     => query($request),
+        '/update'    => updateraw($request),
+        // '/info'      => info(),
+        default      => new Response(404, [], 'Error 404'),
+    };
+}
+
+function text()
+{
+    return new Response(200, [
+        'Content-Type' => 'text/plain',
+        'Date'         => Header::$date
+    ], 'Hello, World!');
+}
+
+function json()
+{
+    return new Response(200, [
+        'Content-Type' => 'application/json',
+        'Date'         => Header::$date
+    ], json_encode(['message' => 'Hello, World!']));
 }
 
 function db()
@@ -143,3 +135,11 @@ function fortune()
     ], "<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>$html</table></body></html>"
     );
 }
+
+/* function info()
+{
+    ob_start();
+    phpinfo();
+    return new Response(200, ['Content-Type' => 'text/plain'], ob_get_clean());
+}
+ */

+ 2 - 25
frameworks/PHP/workerman/benchmark_config.json

@@ -14,7 +14,7 @@
       "database": "MySQL",
       "framework": "workerman",
       "language": "PHP",
-      "flavor": "PHP7",
+      "flavor": "PHP8",
       "orm": "Raw",
       "platform": "workerman",
       "webserver": "None",
@@ -35,7 +35,7 @@
       "database": "Postgres",
       "framework": "workerman",
       "language": "PHP",
-      "flavor": "PHP7",
+      "flavor": "PHP8",
       "orm": "Raw",
       "platform": "workerman",
       "webserver": "None",
@@ -64,29 +64,6 @@
       "notes": "",
       "versus": "php"
     },
-    "php8": {
-      "json_url": "/json",
-      "plaintext_url": "/plaintext",
-      "db_url": "/db",
-      "query_url": "/query?q=",
-      "update_url": "/update?q=",
-      "fortune_url": "/fortunes",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Platform",
-      "database": "Postgres",
-      "framework": "workerman",
-      "language": "PHP",
-      "flavor": "PHP8",
-      "orm": "Raw",
-      "platform": "workerman",
-      "webserver": "None",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "workerman-php8",
-      "notes": "",
-      "versus": "php"
-    },
     "php8-jit": {
       "json_url": "/json",
       "plaintext_url": "/plaintext",

+ 2 - 2
frameworks/PHP/workerman/workerman-async.dockerfile

@@ -5,12 +5,12 @@ 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
 RUN apt-get update -yqq > /dev/null && \
-    apt-get install -yqq php7.4 php7.4-common php7.4-cli php7.4-mysql  > /dev/null
+    apt-get install -yqq php7.4-cli php7.4-mysql  > /dev/null
 
 RUN apt-get install -yqq composer > /dev/null
 
 RUN apt-get install -y php-pear php7.4-dev libevent-dev > /dev/null
-RUN printf "\n\n /usr/lib/x86_64-linux-gnu/\n\n\nno\n\n\n" | pecl install event > /dev/null && echo "extension=event.so" > /etc/php/7.4/cli/conf.d/event.ini
+RUN pecl install event > /dev/null && echo "extension=event.so" > /etc/php/7.4/cli/conf.d/event.ini
 
 COPY php.ini /etc/php/7.4/cli/php.ini
 

+ 4 - 4
frameworks/PHP/workerman/workerman-pgsql.dockerfile

@@ -5,14 +5,14 @@ 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
 RUN apt-get update -yqq > /dev/null && \
-    apt-get install -yqq php7.4 php7.4-common php7.4-cli php7.4-pgsql php7.4-xml > /dev/null
+    apt-get install -yqq php8.0-cli php8.0-pgsql php8.0-xml > /dev/null
 
 RUN apt-get install -yqq composer > /dev/null
 
-RUN apt-get install -y php-pear php7.4-dev libevent-dev > /dev/null
-RUN printf "\n\n /usr/lib/x86_64-linux-gnu/\n\n\nno\n\n\n" | pecl install event > /dev/null && echo "extension=event.so" > /etc/php/7.4/cli/conf.d/event.ini
+RUN apt-get install -y php-pear php8.0-dev libevent-dev > /dev/null
+RUN pecl install event-3.0.2 > /dev/null && echo "extension=event.so" > /etc/php/8.0/cli/conf.d/event.ini
 
-COPY php.ini /etc/php/7.4/cli/php.ini
+COPY php.ini /etc/php/8.0/cli/php.ini
 
 ADD ./ /workerman
 WORKDIR /workerman

+ 3 - 18
frameworks/PHP/workerman/workerman-php8-jit.dockerfile

@@ -5,27 +5,12 @@ 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
 RUN apt-get update -yqq > /dev/null && \
-    apt-get install -yqq php8.0 php8.0-common php8.0-cli php8.0-pgsql php8.0-xml > /dev/null
+    apt-get install -yqq php8.0-cli php8.0-pgsql php8.0-xml > /dev/null
 
 RUN apt-get install -yqq composer > /dev/null
 
-RUN apt-get install -y php8.0-dev libevent-dev > /dev/null
-#RUN apt-get install -y php-pear php8.0-dev libevent-dev php8.0-mbstring php8.0-simplexml php8.0-zip > /dev/null
-#RUN curl -sSL https://pear.php.net/go-pear.phar -o pear > /dev/null \
-#        && pear install event \
-#        && echo "extension=event.so" > /etc/php/8.0/cli/conf.d/event.ini
-
-#RUN curl -sSL https://github.com/FriendsOfPHP/pickle/releases/latest/download/pickle.phar -o /usr/local/bin/pickle \
-#        && chmod +x /usr/local/bin/pickle
-#RUN pickle install event && echo "extension=event.so" > /etc/php/8.0/cli/conf.d/event.ini
-
-RUN curl -sSL https://bitbucket.org/osmanov/pecl-event/get/3.0.0-beta.1.zip -o event.zip \
-        && unzip -qq event.zip \
-        && cd osmanov-pecl-event-efcc0739aac6 \
-        && phpize > /dev/null \
-        && ./configure --with-event-core --with-event-extra \
-        && make > /dev/null && make install > /dev/null \
-        && echo "extension=event.so" > /etc/php/8.0/cli/conf.d/event.ini
+RUN apt-get install -y php-pear php8.0-dev libevent-dev > /dev/null
+RUN pecl install event-3.0.2 > /dev/null && echo "extension=event.so" > /etc/php/8.0/cli/conf.d/event.ini
  
 COPY php-jit.ini /etc/php/8.0/cli/php.ini
 

+ 0 - 39
frameworks/PHP/workerman/workerman-php8.dockerfile

@@ -1,39 +0,0 @@
-FROM ubuntu:20.10
-
-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
-RUN apt-get update -yqq > /dev/null && \
-    apt-get install -yqq php8.0 php8.0-common php8.0-cli php8.0-pgsql php8.0-xml > /dev/null
-
-RUN apt-get install -yqq composer > /dev/null
-
-RUN apt-get install -y php8.0-dev libevent-dev > /dev/null
-#RUN apt-get install -y php-pear php8.0-dev libevent-dev php8.0-mbstring php8.0-simplexml php8.0-zip > /dev/null
-#RUN curl -sSL https://pear.php.net/go-pear.phar -o pear > /dev/null \
-#        && pear install event \
-#        && echo "extension=event.so" > /etc/php/8.0/cli/conf.d/event.ini
-
-#RUN curl -sSL https://github.com/FriendsOfPHP/pickle/releases/latest/download/pickle.phar -o /usr/local/bin/pickle \
-#        && chmod +x /usr/local/bin/pickle
-#RUN pickle install event && echo "extension=event.so" > /etc/php/8.0/cli/conf.d/event.ini
-
-RUN curl -sSL https://bitbucket.org/osmanov/pecl-event/get/3.0.0-beta.1.zip -o event.zip \
-        && unzip -qq event.zip \
-        && cd osmanov-pecl-event-efcc0739aac6 \
-        && phpize > /dev/null \
-        && ./configure --with-event-core --with-event-extra \
-        && make > /dev/null && make install > /dev/null \
-        && echo "extension=event.so" > /etc/php/8.0/cli/conf.d/event.ini
- 
-COPY php.ini /etc/php/8.0/cli/php.ini
-
-ADD ./ /workerman
-WORKDIR /workerman
-
-RUN sed -i "s|'mysql:host|'pgsql:host|g" app.php
-
-RUN composer install --optimize-autoloader --classmap-authoritative --no-dev --quiet
-
-CMD php /workerman/server.php start

+ 5 - 5
frameworks/PHP/workerman/workerman.dockerfile

@@ -5,14 +5,14 @@ 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
 RUN apt-get update -yqq > /dev/null && \
-    apt-get install -yqq php7.4 php7.4-common php7.4-cli php7.4-xml php7.4-mysql  > /dev/null
+    apt-get install -yqq php8.0-cli php8.0-mysql php8.0-xml > /dev/null
 
 RUN apt-get install -yqq composer > /dev/null
 
-RUN apt-get install -y php-pear php-dev libevent-dev > /dev/null
-RUN printf "\n\n /usr/lib/x86_64-linux-gnu/\n\n\nno\n\n\n" | pecl install event > /dev/null && echo "extension=event.so" > /etc/php/7.4/cli/conf.d/event.ini
-
-COPY php.ini /etc/php/7.4/cli/php.ini
+RUN apt-get install -y php-pear php8.0-dev libevent-dev > /dev/null
+RUN pecl install event-3.0.2 > /dev/null && echo "extension=event.so" > /etc/php/8.0/cli/conf.d/event.ini
+ 
+COPY php.ini /etc/php/8.0/cli/php.ini
 
 ADD ./ /workerman
 WORKDIR /workerman