Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[php] Kumbiaphp update to PHP 8.3 #8632

Merged
merged 6 commits into from
Dec 11, 2023
Merged
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
14 changes: 7 additions & 7 deletions frameworks/PHP/kumbiaphp/bench/app/controllers/ku_controller.php
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -20,22 +18,24 @@ public function index()
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);
}

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;
Expand Down
1 change: 1 addition & 0 deletions frameworks/PHP/kumbiaphp/bench/app/models/fortune.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

#[\AllowDynamicProperties]
class Fortune extends \Kumbia\ActiveRecord\LiteRecord
{

Expand Down
1 change: 1 addition & 0 deletions frameworks/PHP/kumbiaphp/bench/app/models/world.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

#[\AllowDynamicProperties]
class World extends \Kumbia\ActiveRecord\LiteRecord
{
public static function byId($id)
Expand Down
2 changes: 1 addition & 1 deletion frameworks/PHP/kumbiaphp/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"workerman/workerman": "^3.5"
"joanhey/adapterman": "^0.6"
}
}
2 changes: 2 additions & 0 deletions frameworks/PHP/kumbiaphp/deploy/conf/cliphp.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 9 additions & 8 deletions frameworks/PHP/kumbiaphp/kumbiaphp-raw.dockerfile
Original file line number Diff line number Diff line change
@@ -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
19 changes: 10 additions & 9 deletions frameworks/PHP/kumbiaphp/kumbiaphp-workerman-mysql.dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
15 changes: 5 additions & 10 deletions frameworks/PHP/kumbiaphp/kumbiaphp-workerman.dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 9 additions & 8 deletions frameworks/PHP/kumbiaphp/kumbiaphp.dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
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 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
12 changes: 8 additions & 4 deletions frameworks/PHP/kumbiaphp/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading