Browse Source

[fat-free] Update to PHP 8 (#6183)

* [fat-free] Update to PHP 8

* Fix fat-free raw
Joan Miquel 4 years ago
parent
commit
3c243daa05

+ 5 - 0
frameworks/PHP/fat-free/composer.json

@@ -0,0 +1,5 @@
+{
+    "require": {
+        "bcosca/fatfree-core": "3.7.2"
+    }
+}

+ 2 - 3
frameworks/PHP/fat-free/deploy/conf/php-fpm.conf

@@ -14,14 +14,13 @@
 ; Pid file
 ; Note: the default prefix is /var
 ; Default Value: none
-pid = /run/php/php7.3-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.3-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 = /run/php/php7.3-fpm.sock
+listen = /run/php/php-fpm.sock
 
 ; Set listen(2) backlog.
 ; Default Value: 511 (-1 on FreeBSD and OpenBSD)

+ 2 - 1
frameworks/PHP/fat-free/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;
@@ -41,7 +42,7 @@ http {
 
 
     upstream fastcgi_backend {
-        server unix:/var/run/php/php7.3-fpm.sock;
+        server unix:/var/run/php/php-fpm.sock;
         keepalive 40;
     }
 

+ 9 - 7
frameworks/PHP/fat-free/fat-free-raw.dockerfile

@@ -1,24 +1,26 @@
-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 ./ /fat-free
 WORKDIR /fat-free
 
 ENV F3DIR="/fat-free/src"
 
-RUN git clone -b 3.7.1 --single-branch --depth 1 "https://github.com/bcosca/fatfree-core.git" src
+RUN apt-get install -yqq composer > /dev/null
 
-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 composer install --optimize-autoloader --classmap-authoritative --no-dev --quiet
+
+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 /fat-free
 
-CMD service php7.4-fpm start && \
-    nginx -c /fat-free/deploy/nginx.conf -g "daemon off;"
+CMD service php8.0-fpm start && \
+    nginx -c /fat-free/deploy/nginx.conf

+ 11 - 7
frameworks/PHP/fat-free/fat-free.dockerfile

@@ -1,24 +1,28 @@
-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 ./ /fat-free
 WORKDIR /fat-free
 
 ENV F3DIR="/fat-free/src"
 
-RUN git clone -b 3.7.1 --single-branch --depth 1 "https://github.com/bcosca/fatfree-core.git" src
+#RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer 
+RUN apt-get install -yqq composer > /dev/null
 
-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 composer install --optimize-autoloader --classmap-authoritative --no-dev --quiet
+#RUN git clone -b 3.7.2 --single-branch --depth 1 "https://github.com/bcosca/fatfree-core.git" src
+
+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 /fat-free
 
-CMD service php7.4-fpm start && \
-    nginx -c /fat-free/deploy/nginx.conf -g "daemon off;"
+CMD service php8.0-fpm start && \
+    nginx -c /fat-free/deploy/nginx.conf

+ 2 - 1
frameworks/PHP/fat-free/index.php

@@ -4,9 +4,10 @@
 //     error_clear_last();
 
 // error_reporting(0);
+require_once 'vendor/autoload.php';
 
 /** @var Base $f3 */
-$f3 = require('src/base.php');
+$f3 = \Base::instance();
 
 error_reporting(-1);