Browse Source

Phalcon update to v4.0 and php 7.4 (#5461)

Joan Miquel 5 years ago
parent
commit
dd937e55af

+ 3 - 2
frameworks/PHP/phalcon/app/models/Fortunes.php

@@ -6,7 +6,8 @@ class Fortunes extends \Phalcon\Mvc\Model
 
     public $message;
 
-    public function getSource() {
-        return "Fortune";
+    public function initialize()
+    {
+        $this->setSource('Fortune');
     }
 }

+ 3 - 2
frameworks/PHP/phalcon/app/models/Worlds.php

@@ -6,7 +6,8 @@ class Worlds extends \Phalcon\Mvc\Model
 
     public $randomNumber;
 
-    public function getSource() {
-        return "World";
+    public function initialize()
+    {
+        $this->setSource('World');
     }
 }

+ 3 - 3
frameworks/PHP/phalcon/deploy/conf/php-fpm.conf

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

+ 1 - 1
frameworks/PHP/phalcon/deploy/nginx.conf

@@ -41,7 +41,7 @@ http {
 
 
     upstream fastcgi_backend {
-        server unix:/var/run/php/php7.3-fpm.sock;
+        server unix:/var/run/php/php7.4-fpm.sock;
         keepalive 40;
     }
 

+ 7 - 7
frameworks/PHP/phalcon/phalcon.dockerfile

@@ -1,26 +1,26 @@
-FROM ubuntu:19.04
+FROM ubuntu:19.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.3 php7.3-common php7.3-cli php7.3-fpm php7.3-mysql php7.3-mongodb  > /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-mongodb  > /dev/null
 
 RUN apt-get install -yqq composer > /dev/null
 
-COPY deploy/conf/* /etc/php/7.3/fpm/
+COPY deploy/conf/* /etc/php/7.4/fpm/
 
 ADD ./ /phalcon
 WORKDIR /phalcon
 
-RUN apt-get install -yqq php7.3-phalcon  > /dev/null
+RUN apt-get install -yqq php7.4-phalcon  > /dev/null
 
-RUN if [ $(nproc) = 2 ]; then sed -i "s|pm.max_children = 1024|pm.max_children = 512|g" /etc/php/7.3/fpm/php-fpm.conf ; fi;
+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 composer install --optimize-autoloader --classmap-authoritative --no-dev --ignore-platform-reqs
 
 RUN chmod -R 777 app
 
-CMD service php7.3-fpm start && \
+CMD service php7.4-fpm start && \
     nginx -c /phalcon/deploy/nginx.conf -g "daemon off;"

+ 7 - 6
frameworks/PHP/phalcon/public/index.php

@@ -40,14 +40,14 @@ try {
         $view->setViewsDir($config->application->viewsDir);
 
         $view->registerEngines(array(
-            ".volt" => function($view, $di) {
+            ".volt" => function($view) {
 
-                $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di);
+                $volt = new \Phalcon\Mvc\View\Engine\Volt($view);
 
                 $volt->setOptions(array(
-                    "compiledPath" => APP_PATH . "/app/compiled-templates/",
-                    "compiledExtension" => ".compiled",
-                    "compiledSeparator" => '_',
+                    "path" => APP_PATH . "/app/compiled-templates/",
+                    "extension" => ".compiled",
+                    "separator" => '_',
                 ));
 
                 return $volt;
@@ -92,9 +92,10 @@ try {
     }, true);
 
     // Handle the request
+    $request = new Phalcon\Http\Request();
     $application = new \Phalcon\Mvc\Application();
     $application->setDI($di);
-    echo $application->handle()->getContent();
+    echo $application->handle($request->getURI())->getContent();
 
 } catch(\Phalcon\Exception $e) {
     echo "PhalconException: ", $e->getMessage();