Browse Source

[php] Kumbiaphp update to PHP 8.3 (#8632)

* [php] Kumbiaphp update to PHP 8.3

* delete commented line

* Fix docker

* Fix dockerfile

* Fix dockerfile branch

* Fixed
Joan Miquel 1 year ago
parent
commit
d0067c2665

+ 7 - 7
frameworks/PHP/kumbiaphp/bench/app/controllers/ku_controller.php

@@ -1,14 +1,12 @@
 <?php
 
-use Workerman\Protocols\Http;
-
 class KuController extends AppController
 {
 
     protected function before_filter()
     {
         View::select(null, null);
-        Http::header('Content-Type: application/json');
+        header('Content-Type: application/json');
     }
 
     public function index()
@@ -20,10 +18,11 @@ class KuController extends AppController
     public function query($count = 1)
     {
         $count = min(max((int) $count, 1), 500);
+        $random = KuRaw::$random;
 
         while ($count--) {
-            KuRaw::$random->execute([mt_rand(1, 10000)]);
-            $worlds[] = KuRaw::$random->fetch();
+            $random->execute([mt_rand(1, 10000)]);
+            $worlds[] = $random->fetch();
         }
         echo json_encode($worlds);
     }
@@ -31,11 +30,12 @@ class KuController extends AppController
     public function update($count = 1)
     {
         $count = min(max((int) $count, 1), 500);
+        $random = KuRaw::$random;
 
         while ($count--) {
 
-            KuRaw::$random->execute([mt_rand(1, 10000)]);
-            $row = KuRaw::$random->fetch();
+            $random->execute([mt_rand(1, 10000)]);
+            $row = $random->fetch();
             $row['randomNumber'] = mt_rand(1, 10000);
 
             $worlds[] = $row;

+ 1 - 0
frameworks/PHP/kumbiaphp/bench/app/models/fortune.php

@@ -1,5 +1,6 @@
 <?php
 
+#[\AllowDynamicProperties]
 class Fortune extends \Kumbia\ActiveRecord\LiteRecord
 {
 

+ 1 - 0
frameworks/PHP/kumbiaphp/bench/app/models/world.php

@@ -1,5 +1,6 @@
 <?php
 
+#[\AllowDynamicProperties]
 class World extends \Kumbia\ActiveRecord\LiteRecord
 {
     public static function byId($id)

+ 1 - 1
frameworks/PHP/kumbiaphp/composer.json

@@ -1,5 +1,5 @@
 {
 	"require": {
-		"workerman/workerman": "^3.5"
+		"joanhey/adapterman": "^0.6"
 	}
 }

+ 2 - 0
frameworks/PHP/kumbiaphp/deploy/conf/cliphp.ini

@@ -12,3 +12,5 @@ memory_limit = 512M
 
 opcache.jit_buffer_size=128M
 opcache.jit=tracing
+
+disable_functions=header,header_remove,headers_sent,http_response_code,setcookie,session_create_id,session_id,session_name,session_save_path,session_status,session_start,session_write_close,session_regenerate_id,set_time_limit

+ 9 - 8
frameworks/PHP/kumbiaphp/kumbiaphp-raw.dockerfile

@@ -1,23 +1,24 @@
-FROM ubuntu:20.04
+FROM ubuntu:22.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
-RUN apt-get update -yqq > /dev/null && \
-    apt-get install -yqq nginx git unzip \
-    php8.1-fpm php8.1-mysql php8.1-dev > /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
 
-COPY deploy/conf/* /etc/php/8.1/fpm/
+RUN apt-get install -yqq nginx git unzip \
+    php8.3-fpm php8.3-mysql > /dev/null
+
+COPY deploy/conf/* /etc/php/8.3/fpm/
 
 ADD ./ /kumbiaphp
 WORKDIR /kumbiaphp
 
 RUN git clone -b v1.1.4 --single-branch --depth 1 -q https://github.com/KumbiaPHP/KumbiaPHP.git vendor/Kumbia
 
-RUN if [ $(nproc) = 2 ]; then sed -i "s|pm.max_children = 1024|pm.max_children = 512|g" /etc/php/8.1/fpm/php-fpm.conf ; fi;
+RUN if [ $(nproc) = 2 ]; then sed -i "s|pm.max_children = 1024|pm.max_children = 512|g" /etc/php/8.3/fpm/php-fpm.conf ; fi;
 
 EXPOSE 8080
 
-CMD service php8.1-fpm start && \
+CMD service php8.3-fpm start && \
     nginx -c /kumbiaphp/deploy/nginx.conf

+ 10 - 9
frameworks/PHP/kumbiaphp/kumbiaphp-workerman-mysql.dockerfile

@@ -1,26 +1,27 @@
-FROM ubuntu:20.04
+FROM ubuntu:22.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
-RUN apt-get update -yqq > /dev/null && \
-    apt-get install -yqq git php8.1-cli php8.1-mysql php8.1-xml > /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 install -yqq git php8.3-cli php8.3-mysql php8.3-xml > /dev/null
 
 COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
 
-RUN apt-get install -y php-pear php8.1-dev libevent-dev > /dev/null
-RUN pecl install event-3.0.8 > /dev/null && echo "extension=event.so" > /etc/php/8.1/cli/conf.d/event.ini
+RUN apt-get install -y php-pear php8.3-dev libevent-dev > /dev/null
+RUN pecl install event-3.0.8 > /dev/null && echo "extension=event.so" > /etc/php/8.3/cli/conf.d/event.ini
 
-COPY deploy/conf/cliphp.ini /etc/php/8.1/cli/php.ini
+COPY deploy/conf/cliphp.ini /etc/php/8.3/cli/php.ini
 
 ADD ./ /kumbiaphp
 WORKDIR /kumbiaphp
 
 RUN git clone -b dev --single-branch --depth 1 https://github.com/KumbiaPHP/KumbiaPHP.git vendor/Kumbia
-RUN git clone -b master --single-branch --depth 1 https://github.com/KumbiaPHP/ActiveRecord.git vendor/Kumbia/ActiveRecord
+RUN git clone -b dev --single-branch --depth 1 https://github.com/KumbiaPHP/ActiveRecord.git vendor/Kumbia/ActiveRecord
 
-RUN sed -i "s|header(|\\\Workerman\\\Protocols\\\Http::header(|g" bench/app/controllers/*.php
+RUN sed -i "s|KuRaw::init(|//KuRaw::init(|g" server.php
 
 RUN composer install --optimize-autoloader --classmap-authoritative --no-dev --quiet
 

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

@@ -1,29 +1,24 @@
-FROM ubuntu:20.04
+FROM ubuntu:22.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
 RUN apt-get update -yqq > /dev/null && \
-    apt-get install -yqq git php8.1-cli php8.1-pgsql php8.1-xml > /dev/null
+    apt-get install -yqq git php8.3-cli php8.3-pgsql php8.3-xml > /dev/null
 
 COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
 
-RUN apt-get install -y php-pear php8.1-dev libevent-dev > /dev/null
-RUN pecl install event-3.0.8 > /dev/null && echo "extension=event.so" > /etc/php/8.1/cli/conf.d/event.ini
+RUN apt-get install -y php-pear php8.3-dev libevent-dev > /dev/null
+RUN pecl install event-3.0.8 > /dev/null && echo "extension=event.so" > /etc/php/8.3/cli/conf.d/event.ini
 
-COPY deploy/conf/cliphp.ini /etc/php/8.1/cli/php.ini
+COPY deploy/conf/cliphp.ini /etc/php/8.3/cli/php.ini
 
 ADD ./ /kumbiaphp
 WORKDIR /kumbiaphp
 
 RUN git clone -b dev --single-branch --depth 1 https://github.com/KumbiaPHP/KumbiaPHP.git vendor/Kumbia
 
-#RUN sed -i "s|header(|\\\Workerman\\\Protocols\\\Http::header(|g" bench/app/controllers/{index,json}_controller.php
-RUN sed -i "s|header(|\\\Workerman\\\Protocols\\\Http::header(|g" bench/app/controllers/plaintext_controller.php
-RUN sed -i "s|header(|\\\Workerman\\\Protocols\\\Http::header(|g" bench/app/controllers/json_controller.php
-RUN sed -i "s|//KuRaw::init(|KuRaw::init(|g" server.php
-
 RUN composer install --optimize-autoloader --classmap-authoritative --no-dev --quiet
 
 EXPOSE 8080

+ 9 - 8
frameworks/PHP/kumbiaphp/kumbiaphp.dockerfile

@@ -1,14 +1,15 @@
-FROM ubuntu:20.04
+FROM ubuntu:22.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
-RUN apt-get update -yqq > /dev/null && \
-    apt-get install -yqq nginx git unzip \
-    php8.1-fpm php8.1-mysql php8.1-dev > /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
 
-COPY deploy/conf/* /etc/php/8.1/fpm/
+RUN apt-get install -yqq nginx git unzip \
+    php8.3-fpm php8.3-mysql > /dev/null
+
+COPY deploy/conf/* /etc/php/8.3/fpm/
 
 ADD ./ /kumbiaphp
 WORKDIR /kumbiaphp
@@ -16,9 +17,9 @@ WORKDIR /kumbiaphp
 RUN git clone -b v1.1.4 --single-branch --depth 1 https://github.com/KumbiaPHP/KumbiaPHP.git vendor/Kumbia
 RUN git clone -b dev --single-branch --depth 1 https://github.com/KumbiaPHP/ActiveRecord.git vendor/Kumbia/ActiveRecord
 
-RUN if [ $(nproc) = 2 ]; then sed -i "s|pm.max_children = 1024|pm.max_children = 512|g" /etc/php/8.1/fpm/php-fpm.conf ; fi;
+RUN if [ $(nproc) = 2 ]; then sed -i "s|pm.max_children = 1024|pm.max_children = 512|g" /etc/php/8.3/fpm/php-fpm.conf ; fi;
 
 EXPOSE 8080
 
-CMD service php8.1-fpm start && \
+CMD service php8.3-fpm start && \
     nginx -c /kumbiaphp/deploy/nginx.conf

+ 8 - 4
frameworks/PHP/kumbiaphp/server.php

@@ -2,14 +2,18 @@
 require_once __DIR__.'/vendor/autoload.php';
 require_once __DIR__.'/bench/app/workerbootstrap.php';
 
+use Adapterman\Adapterman;
 use Workerman\Worker;
 
-$http_worker                = new Worker('http://0.0.0.0:8080');
-$http_worker->count         = (int) shell_exec('nproc') * 4;
-$http_worker->onWorkerStart = static function () {
+Adapterman::init();
+
+$http_worker            = new Worker('http://0.0.0.0:8080');
+$http_worker->count     = (int) shell_exec('nproc') * 4;
+$http_worker->name      = 'KumbiaPHP';
 
+$http_worker->onWorkerStart = static function () {
     kumbiaInit();
-    //KuRaw::init();
+    KuRaw::init();
 };
 
 $http_worker->onMessage = static function ($connection) {