Skip to content

Commit

Permalink
[duckphp] Update to PHP8 (#6311)
Browse files Browse the repository at this point in the history
* [duckphp] Update to PHP8

* Fix for duckphp v1.2.10

* Fix vartiables to int

* Faster array combine in fortunes

* Clean dockerfile
Changed to test a bug
  • Loading branch information
joanhey authored Jan 20, 2021
1 parent 94a010b commit b30a82d
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 21 deletions.
4 changes: 2 additions & 2 deletions frameworks/PHP/duckphp/app/Controller/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion frameworks/PHP/duckphp/app/Model/FortuneModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions frameworks/PHP/duckphp/app/System/BaseBusiness.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

namespace DuckPhpBenchmark\System;

use DuckPhp\SingletonEx\SingletonEx;
use DuckPhp\SingletonEx\SingletonExTrait;

class BaseBusiness
{
use SingletonEx;
use SingletonExTrait;
}
4 changes: 2 additions & 2 deletions frameworks/PHP/duckphp/app/System/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 1 addition & 2 deletions frameworks/PHP/duckphp/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" : {
Expand Down
5 changes: 2 additions & 3 deletions frameworks/PHP/duckphp/deploy/conf/php-fpm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion frameworks/PHP/duckphp/deploy/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ user www-data;
worker_processes auto;
error_log stderr error;
worker_rlimit_nofile 200000;
daemon off;

events {
worker_connections 16384;
Expand Down Expand Up @@ -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;
}

Expand Down
15 changes: 7 additions & 8 deletions frameworks/PHP/duckphp/duckphp.dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
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

EXPOSE 8080

CMD service php7.4-fpm start && \
nginx -c /duckphp/deploy/nginx.conf -g "daemon off;"
CMD service php8.0-fpm start && \
nginx -c /duckphp/deploy/nginx.conf

0 comments on commit b30a82d

Please sign in to comment.