Browse Source

Update to PHP 8 (#6169)

* Update to PHP 8

* Update eloquent to 8.16

* Fix for PHP 8

* Delete PHP ActiveRecord
Joan Miquel 4 years ago
parent
commit
e432178aac

+ 0 - 19
frameworks/PHP/php/benchmark_config.json

@@ -24,25 +24,6 @@
       "notes": "",
       "versus": "php"
     },
-    "activerecord": {
-      "db_url": "/dborm.php",
-      "query_url": "/dborm.php?queries=",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Platform",
-      "database": "MySQL",
-      "framework": "None",
-      "language": "PHP",
-      "flavor": "PHP7",
-      "orm": "Full",
-      "platform": "FPM/FastCGI",
-      "webserver": "nginx",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "PHP-activerecord",
-      "notes": "",
-      "versus": "php"
-    },
     "raw7-tcp": {
       "json_url": "/json.php",
       "plaintext_url": "/plaintext.php",

+ 0 - 39
frameworks/PHP/php/dborm.php

@@ -1,39 +0,0 @@
-<?php
-// Set content type
-header('Content-Type: application/json');
-
-// Database connection
-// http://www.php.net/manual/en/ref.pdo-mysql.php
-// $pdo = new PDO('mysql:host=tfb-database;dbname=hello_world', 'benchmarkdbuser', 'benchmarkdbpass');
-
-# inclue the ActiveRecord library
-require 'vendor/php-activerecord/php-activerecord/ActiveRecord.php';
-
-ActiveRecord\Connection::$PDO_OPTIONS[PDO::ATTR_PERSISTENT] = true;
-ActiveRecord\Config::initialize(function ($cfg) {
-    $cfg->set_model_directory('models');
-    $cfg->set_connections(['development' =>
-        'mysql://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world']);
-});
-
-if (! isset($_GET['queries'])) {
-    echo json_encode( World::find_by_id(mt_rand(1, 10000))->to_array(), JSON_NUMERIC_CHECK);
-    return;
-}
-
-// Read number of queries to run from URL parameter
-$query_count = 1;
-if ($_GET['queries'] > 1) {
-    $query_count = $_GET['queries'] > 500 ? 500 : $_GET['queries'];
-}
-// Create an array with the response string.
-$arr = [];
-// For each query, store the result set values in the response array
-while ($query_count--) {
-    // Store result in array.
-    $arr[] = World::find_by_id(mt_rand(1, 10000))->to_array();
-}
-
-// Use the PHP standard JSON encoder.
-// http://www.php.net/manual/en/function.json-encode.php
-echo json_encode($arr, JSON_NUMERIC_CHECK);

+ 1 - 1
frameworks/PHP/php/dbquery.php

@@ -9,7 +9,7 @@ $pdo = new PDO('mysql:host=tfb-database;dbname=hello_world', 'benchmarkdbuser',
 
 // Read number of queries to run from URL parameter
 $query_count = 1;
-if ($_GET['queries'] > 1) {
+if ((int) $_GET['queries'] > 1) {
   $query_count = min($_GET['queries'], 500);
 }
 

+ 0 - 5
frameworks/PHP/php/deploy/activerecord/composer.json

@@ -1,5 +0,0 @@
-{
-	"require": {
-    "php-activerecord/php-activerecord": "1.2.0"
-	}
-}

+ 3 - 3
frameworks/PHP/php/deploy/eloquent/composer.json

@@ -1,7 +1,7 @@
 {
   "require": {
-    "illuminate/database": "5.8.*",
-    "illuminate/events": "5.8.*",
-    "illuminate/container": "5.8.*"
+    "illuminate/database": "8.16.*",
+    "illuminate/events": "8.16.*",
+    "illuminate/container": "8.16.*"
   }
 }

+ 1 - 1
frameworks/PHP/php/eloquent/db-eloquent.php

@@ -11,7 +11,7 @@ if (! isset($_GET['queries'])) {
 
 // Read number of queries to run from URL parameter
 $query_count = 1;
-if ($_GET['queries'] > 1) {
+if ((int) $_GET['queries'] > 1) {
     $query_count = $_GET['queries'] > 500 ? 500 : $_GET['queries'];
 }
 // Create an array with the response string.

+ 1 - 1
frameworks/PHP/php/eloquent/db-laravel-query-builder.php

@@ -15,7 +15,7 @@ if (! isset($_GET['queries'])) {
 
 // Read number of queries to run from URL parameter
 $query_count = 1;
-if ($_GET['queries'] > 1) {
+if ((int) $_GET['queries'] > 1) {
     $query_count = $_GET['queries'] > 500 ? 500 : $_GET['queries'];
 }
 // Create an array with the response string.

+ 1 - 1
frameworks/PHP/php/eloquent/update-eloquent.php

@@ -4,7 +4,7 @@ require_once __DIR__ . '/boot-eloquent.php';
 
 // Read number of queries to run from URL parameter
 $query_count = 1;
-if (isset($_GET['queries']) && $_GET['queries'] > 0) {
+if (isset($_GET['queries']) && (int) $_GET['queries'] > 0) {
   $query_count = $_GET['queries'] > 500 ? 500 : $_GET['queries'];
 }
 

+ 0 - 25
frameworks/PHP/php/php-activerecord.dockerfile

@@ -1,25 +0,0 @@
-FROM ubuntu:20.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 php7.4 php7.4-common php7.4-cli php7.4-fpm php7.4-mysql  > /dev/null
-
-RUN apt-get install -yqq composer > /dev/null
-
-COPY deploy/conf/* /etc/php/7.4/fpm/
-
-ADD ./ /php
-WORKDIR /php
-
-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;
-
-COPY deploy/activerecord/composer* ./
-RUN composer install --optimize-autoloader --classmap-authoritative --no-dev --quiet
-
-RUN chmod -R 777 /php
-
-CMD service php7.4-fpm start && \
-    nginx -c /php/deploy/nginx7.conf -g "daemon off;"

+ 5 - 5
frameworks/PHP/php/php-eloquent.dockerfile

@@ -1,25 +1,25 @@
-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  php7.4-mbstring > /dev/null
+    apt-get install -yqq nginx git unzip php8.0 php8.0-common php8.0-cli php8.0-fpm php8.0-mysql  php8.0-mbstring > /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 ./ /php
 WORKDIR /php
 
-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;
 
 COPY deploy/eloquent/composer* ./
 RUN composer install --optimize-autoloader --classmap-authoritative --no-dev --quiet
 
 RUN chmod -R 777 /php
 
-CMD service php7.4-fpm start && \
+CMD service php8.0-fpm start && \
     nginx -c /php/deploy/nginx7.conf -g "daemon off;"

+ 5 - 5
frameworks/PHP/php/php-h2o.dockerfile

@@ -1,4 +1,4 @@
-FROM ubuntu:20.04
+FROM ubuntu:20.10
 
 COPY ./ ./
 
@@ -12,11 +12,11 @@ RUN apt-get update > /dev/null && \
 ### Install php
 RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php > /dev/null
 RUN apt-get update -yqq > /dev/null && \
-    apt-get install -yqq php7.4 php7.4-common php7.4-cli php7.4-fpm php7.4-mysql  > /dev/null
+    apt-get install -yqq php8.0 php8.0-common php8.0-cli php8.0-fpm php8.0-mysql  > /dev/null
 
-COPY deploy/conf/* /etc/php/7.4/fpm/
+COPY deploy/conf/* /etc/php/8.0/fpm/
 
-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;
 
 ### Install h2o
 
@@ -33,5 +33,5 @@ RUN wget -qO "$H2O_ARCHIVE" "https://github.com/h2o/h2o/archive/$H2O_ARCHIVE" &&
 
 CMD export WORKERS=$(( 2 * $(nproc) )) && \
     sed -i "s/num-threads: x/num-threads: $WORKERS/g" /deploy/h2o.conf && \
-    service php7.4-fpm start && \
+    service php8.0-fpm start && \
     /h2o/bin/h2o -c /deploy/h2o.conf

+ 5 - 5
frameworks/PHP/php/php-laravel-query-builder.dockerfile

@@ -1,25 +1,25 @@
-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  php7.4-mbstring > /dev/null
+    apt-get install -yqq nginx git unzip php8.0 php8.0-common php8.0-cli php8.0-fpm php8.0-mysql  php8.0-mbstring > /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 ./ /php
 WORKDIR /php
 
-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;
 
 COPY deploy/eloquent/composer* ./
 RUN composer install --optimize-autoloader --classmap-authoritative --no-dev --quiet
 
 RUN chmod -R 777 /php
 
-CMD service php7.4-fpm start && \
+CMD service php8.0-fpm start && \
     nginx -c /php/deploy/nginx7.conf -g "daemon off;"

+ 5 - 5
frameworks/PHP/php/php-pgsql-raw.dockerfile

@@ -1,13 +1,13 @@
-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-pgsql  > /dev/null
+    apt-get install -yqq nginx git unzip php8.0 php8.0-common php8.0-cli php8.0-fpm php8.0-pgsql  > /dev/null
 
-COPY deploy/conf/* /etc/php/7.4/fpm/
+COPY deploy/conf/* /etc/php/8.0/fpm/
 
 ADD ./ /php
 WORKDIR /php
@@ -17,9 +17,9 @@ RUN sed -i "s|PDO('mysql:|PDO('pgsql:|g" dbquery.php
 RUN sed -i "s|PDO('mysql:|PDO('pgsql:|g" fortune.php
 RUN sed -i "s|PDO('mysql:|PDO('pgsql:|g" updateraw.php
 
-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 chmod -R 777 /php
 
-CMD service php7.4-fpm start && \
+CMD service php8.0-fpm start && \
     nginx -c /php/deploy/nginx7.conf -g "daemon off;"

+ 6 - 6
frameworks/PHP/php/php-pools.dockerfile

@@ -1,21 +1,21 @@
-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 php8.0-common php8.0-cli php8.0-fpm php8.0-mysql  > /dev/null
 
-COPY deploy/conf/* /etc/php/7.4/fpm/
+COPY deploy/conf/* /etc/php/8.0/fpm/
 
 ADD ./ /php
 WORKDIR /php
 
-COPY deploy/conf/php-fpm-pools.conf /etc/php/7.4/fpm/php-fpm.conf
-RUN if [ $(nproc) = 2 ]; then sed -i "s|pm.max_children = 512|pm.max_children = 256|g" /etc/php/7.4/fpm/php-fpm.conf ; fi;
+COPY deploy/conf/php-fpm-pools.conf /etc/php/8.0/fpm/php-fpm.conf
+RUN if [ $(nproc) = 2 ]; then sed -i "s|pm.max_children = 512|pm.max_children = 256|g" /etc/php/8.0/fpm/php-fpm.conf ; fi;
 
 RUN chmod -R 777 /php
 
-CMD service php7.4-fpm start && \
+CMD service php8.0-fpm start && \
     nginx -c /php/deploy/nginx-pools.conf -g "daemon off;"

+ 6 - 6
frameworks/PHP/php/php-raw7-tcp.dockerfile

@@ -1,23 +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 php8.0-common php8.0-cli php8.0-fpm php8.0-mysql  > /dev/null
 
-COPY deploy/conf/* /etc/php/7.4/fpm/
+COPY deploy/conf/* /etc/php/8.0/fpm/
 
 ADD ./ /php
 WORKDIR /php
 
-RUN sed -i "s|listen = /run/php/php-fpm.sock|listen = 127.0.0.1:9001|g" /etc/php/7.4/fpm/php-fpm.conf
+RUN sed -i "s|listen = /run/php/php-fpm.sock|listen = 127.0.0.1:9001|g" /etc/php/8.0/fpm/php-fpm.conf
 RUN sed -i "s|server unix:/var/run/php/php-fpm.sock;|server 127.0.0.1:9001;|g" deploy/nginx7.conf
 
-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 chmod -R 777 /php
 
-CMD service php7.4-fpm start && \
+CMD service php8.0-fpm start && \
     nginx -c /php/deploy/nginx7.conf -g "daemon off;"

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

@@ -1,20 +1,20 @@
-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 php8.0-common php8.0-cli php8.0-fpm php8.0-mysql  > /dev/null
 
-COPY deploy/conf/* /etc/php/7.4/fpm/
+COPY deploy/conf/* /etc/php/8.0/fpm/
 
 ADD ./ /php
 WORKDIR /php
 
-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 chmod -R 777 /php
 
-CMD service php7.4-fpm start && \
+CMD service php8.0-fpm start && \
     nginx -c /php/deploy/nginx7.conf -g "daemon off;"

+ 1 - 1
frameworks/PHP/php/updateraw.php

@@ -10,7 +10,7 @@ $pdo = new PDO('mysql:host=tfb-database;dbname=hello_world', 'benchmarkdbuser',
 
 // Read number of queries to run from URL parameter
 $query_count = 1;
-if ($_GET['queries'] > 1) {
+if ((int) $_GET['queries'] > 1) {
   $query_count = min($_GET['queries'], 500);
 }