From f9e1565400a05b7096f7b15eda0a1c58774884c8 Mon Sep 17 00:00:00 2001 From: Joanhey Date: Wed, 20 Jan 2021 13:57:06 +0100 Subject: [PATCH 1/5] [duckphp] Update to PHP8 --- frameworks/PHP/duckphp/composer.json | 3 +-- frameworks/PHP/duckphp/deploy/conf/php-fpm.conf | 5 ++--- frameworks/PHP/duckphp/deploy/nginx.conf | 3 ++- frameworks/PHP/duckphp/duckphp.dockerfile | 16 ++++++++-------- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/frameworks/PHP/duckphp/composer.json b/frameworks/PHP/duckphp/composer.json index 53287ccd044..c4f3f950d78 100644 --- a/frameworks/PHP/duckphp/composer.json +++ b/frameworks/PHP/duckphp/composer.json @@ -2,8 +2,7 @@ "name": "dvaknheo/duckphp-benchmark", "type": "project", "require" : { - "php" : "^7.2", - "dvaknheo/duckphp" : "1.2.7" + "dvaknheo/duckphp" : "1.2.10" }, "autoload" : { "psr-4" : { diff --git a/frameworks/PHP/duckphp/deploy/conf/php-fpm.conf b/frameworks/PHP/duckphp/deploy/conf/php-fpm.conf index 39d756209dc..0f1180c79eb 100644 --- a/frameworks/PHP/duckphp/deploy/conf/php-fpm.conf +++ b/frameworks/PHP/duckphp/deploy/conf/php-fpm.conf @@ -14,14 +14,13 @@ ; Pid file ; Note: the default prefix is /var ; Default Value: none -pid = /run/php/php7.4-fpm.pid +pid = /run/php/php-fpm.pid ; Error log file ; If it's set to "syslog", log is sent to syslogd instead of being written ; into a local file. ; Note: the default prefix is /var ; Default Value: log/php-fpm.log -;error_log = /var/log/php7.4-fpm.log error_log = /dev/stderr @@ -161,7 +160,7 @@ group = www-data ; (IPv6 and IPv4-mapped) on a specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. -listen = /var/run/php/php7.4-fpm.sock +listen = /var/run/php/php-fpm.sock ; Set listen(2) backlog. ; Default Value: 511 (-1 on FreeBSD and OpenBSD) diff --git a/frameworks/PHP/duckphp/deploy/nginx.conf b/frameworks/PHP/duckphp/deploy/nginx.conf index 99662e6e2be..3c0e7cf3d6f 100644 --- a/frameworks/PHP/duckphp/deploy/nginx.conf +++ b/frameworks/PHP/duckphp/deploy/nginx.conf @@ -2,6 +2,7 @@ user www-data; worker_processes auto; error_log stderr error; worker_rlimit_nofile 200000; +daemon off; events { worker_connections 16384; @@ -40,7 +41,7 @@ http { upstream fastcgi_backend { - server unix:/var/run/php/php7.4-fpm.sock; + server unix:/var/run/php/php-fpm.sock; keepalive 50; } diff --git a/frameworks/PHP/duckphp/duckphp.dockerfile b/frameworks/PHP/duckphp/duckphp.dockerfile index c156528e6c9..1c3a02a4648 100644 --- a/frameworks/PHP/duckphp/duckphp.dockerfile +++ b/frameworks/PHP/duckphp/duckphp.dockerfile @@ -1,24 +1,24 @@ -FROM ubuntu:20.04 +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 nginx git unzip php7.4 php7.4-common php7.4-cli php7.4-fpm php7.4-mysql > /dev/null + apt-get install -yqq nginx git unzip \ + php8.0-cli php8.0-fpm php8.0-mysql > /dev/null RUN apt-get install -yqq composer > /dev/null -COPY deploy/conf/* /etc/php/7.4/fpm/ +COPY deploy/conf/* /etc/php/8.0/fpm/ ADD ./ /duckphp WORKDIR /duckphp -RUN if [ $(nproc) = 2 ]; then sed -i "s|pm.max_children = 1024|pm.max_children = 512|g" /etc/php/7.4/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.0/fpm/php-fpm.conf ; fi; RUN composer install --optimize-autoloader --classmap-authoritative --no-dev --quiet +#RUN sed -i "s|'controller_base_class' => null|'controller_base_class' => ''|g" vendor/dvaknheo/duckphp/src/Core/Route.php -EXPOSE 8080 - -CMD service php7.4-fpm start && \ - nginx -c /duckphp/deploy/nginx.conf -g "daemon off;" \ No newline at end of file +CMD service php8.0-fpm start && \ + nginx -c /duckphp/deploy/nginx.conf From d5f329b180faa0a958d30fd7c45f6a059caddefa Mon Sep 17 00:00:00 2001 From: Joanhey Date: Wed, 20 Jan 2021 13:58:13 +0100 Subject: [PATCH 2/5] Fix for duckphp v1.2.10 --- frameworks/PHP/duckphp/app/System/BaseBusiness.php | 4 ++-- frameworks/PHP/duckphp/app/System/BaseModel.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frameworks/PHP/duckphp/app/System/BaseBusiness.php b/frameworks/PHP/duckphp/app/System/BaseBusiness.php index 2d36d7d43d7..eeb10903f83 100644 --- a/frameworks/PHP/duckphp/app/System/BaseBusiness.php +++ b/frameworks/PHP/duckphp/app/System/BaseBusiness.php @@ -6,9 +6,9 @@ namespace DuckPhpBenchmark\System; -use DuckPhp\SingletonEx\SingletonEx; +use DuckPhp\SingletonEx\SingletonExTrait; class BaseBusiness { - use SingletonEx; + use SingletonExTrait; } diff --git a/frameworks/PHP/duckphp/app/System/BaseModel.php b/frameworks/PHP/duckphp/app/System/BaseModel.php index 9b3bac30826..f66f2f0ae77 100644 --- a/frameworks/PHP/duckphp/app/System/BaseModel.php +++ b/frameworks/PHP/duckphp/app/System/BaseModel.php @@ -6,10 +6,10 @@ namespace DuckPhpBenchmark\System; -use DuckPhp\SingletonEx\SingletonEx; +use DuckPhp\SingletonEx\SingletonExTrait; class BaseModel { - use SingletonEx; + use SingletonExTrait; // override or add your code here } From 5987d5a0e794f686de2a867a8574106b8c87bb65 Mon Sep 17 00:00:00 2001 From: Joanhey Date: Wed, 20 Jan 2021 13:58:38 +0100 Subject: [PATCH 3/5] Fix vartiables to int --- frameworks/PHP/duckphp/app/Controller/Main.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/PHP/duckphp/app/Controller/Main.php b/frameworks/PHP/duckphp/app/Controller/Main.php index 7232446b780..8ed39d2f825 100644 --- a/frameworks/PHP/duckphp/app/Controller/Main.php +++ b/frameworks/PHP/duckphp/app/Controller/Main.php @@ -36,7 +36,7 @@ public function db() } public function updates() { - $queries = C::GET('queries',1); + $queries = (int) C::GET('queries',1); $query_count = 1; if ($queries > 1) { $query_count = min($queries, 500); @@ -47,7 +47,7 @@ public function updates() } public function queries() { - $queries = C::GET('queries',1); + $queries = (int) C::GET('queries',1); $query_count = 1; if ($queries > 1) { $query_count = min($queries, 500); From ef8653913b19485fc72d51bd209282f43210ab10 Mon Sep 17 00:00:00 2001 From: Joanhey Date: Wed, 20 Jan 2021 13:59:15 +0100 Subject: [PATCH 4/5] Faster array combine in fortunes --- frameworks/PHP/duckphp/app/Model/FortuneModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/PHP/duckphp/app/Model/FortuneModel.php b/frameworks/PHP/duckphp/app/Model/FortuneModel.php index 52cb94dac3d..217a202b212 100644 --- a/frameworks/PHP/duckphp/app/Model/FortuneModel.php +++ b/frameworks/PHP/duckphp/app/Model/FortuneModel.php @@ -15,7 +15,7 @@ public function getFortunes() { $sql = 'SELECT id, message FROM fortune'; $data = M::DB()->fetchAll($sql); - $ret = array_combine(array_column($data,'id'),array_column($data,'message')); + $ret = array_column($data, 'message', 'id'); $ret[0] = 'Additional fortune added at request time.'; asort($ret); return $ret; From bb52ba577013e3e6b878a7bf2db49d7fcb2901e1 Mon Sep 17 00:00:00 2001 From: Joanhey Date: Wed, 20 Jan 2021 14:35:36 +0100 Subject: [PATCH 5/5] Clean dockerfile Changed to test a bug --- frameworks/PHP/duckphp/duckphp.dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/frameworks/PHP/duckphp/duckphp.dockerfile b/frameworks/PHP/duckphp/duckphp.dockerfile index 1c3a02a4648..1028cdf8bc0 100644 --- a/frameworks/PHP/duckphp/duckphp.dockerfile +++ b/frameworks/PHP/duckphp/duckphp.dockerfile @@ -18,7 +18,6 @@ WORKDIR /duckphp RUN if [ $(nproc) = 2 ]; then sed -i "s|pm.max_children = 1024|pm.max_children = 512|g" /etc/php/8.0/fpm/php-fpm.conf ; fi; RUN composer install --optimize-autoloader --classmap-authoritative --no-dev --quiet -#RUN sed -i "s|'controller_base_class' => null|'controller_base_class' => ''|g" vendor/dvaknheo/duckphp/src/Core/Route.php CMD service php8.0-fpm start && \ nginx -c /duckphp/deploy/nginx.conf