Browse Source

Update ubiquity (preloading) (#5390)

* update composer dependencies

* fix Swoole opcache pb

* Add preloading to workerman

* Update preloader.script.php

* Remove SimpleViewController usage

* Remove setModelDatabase for default db
jcheron 5 years ago
parent
commit
0120da9a62

+ 1 - 0
frameworks/PHP/ubiquity/app/config/preloader.script.php

@@ -1,5 +1,6 @@
 <?php
 <?php
 define('APP_ROOT', __DIR__ . '/../');
 define('APP_ROOT', __DIR__ . '/../');
+include_once \APP_ROOT . './../vendor/phpmv/ubiquity/src/Ubiquity/cache/preloading/PreloaderInternalTrait.php';
 include_once \APP_ROOT . './../vendor/phpmv/ubiquity/src/Ubiquity/cache/Preloader.php';
 include_once \APP_ROOT . './../vendor/phpmv/ubiquity/src/Ubiquity/cache/Preloader.php';
 $config = include __DIR__ . '/preloader.config.php';
 $config = include __DIR__ . '/preloader.config.php';
 \Ubiquity\cache\Preloader::fromArray(\APP_ROOT, $config);
 \Ubiquity\cache\Preloader::fromArray(\APP_ROOT, $config);

+ 3 - 2
frameworks/PHP/ubiquity/app/controllers/Db.php

@@ -7,12 +7,13 @@ use models\World;
 /**
 /**
  * Bench controller.
  * Bench controller.
  */
  */
-class Db extends \Ubiquity\controllers\SimpleViewController {
+class Db extends \Ubiquity\controllers\Controller {
+
+	public function __construct() {}
 
 
 	public function initialize() {
 	public function initialize() {
 		\header('Content-Type: application/json');
 		\header('Content-Type: application/json');
 		\Ubiquity\cache\CacheManager::startProd(\Ubiquity\controllers\Startup::$config);
 		\Ubiquity\cache\CacheManager::startProd(\Ubiquity\controllers\Startup::$config);
-		DAO::setModelDatabase(World::class);
 	}
 	}
 
 
 	public function index() {
 	public function index() {

+ 0 - 1
frameworks/PHP/ubiquity/app/controllers/Fortunes.php

@@ -9,7 +9,6 @@ class Fortunes extends \Ubiquity\controllers\SimpleViewController {
 
 
 	public function initialize() {
 	public function initialize() {
 		\Ubiquity\cache\CacheManager::startProd(Startup::$config);
 		\Ubiquity\cache\CacheManager::startProd(Startup::$config);
-		DAO::setModelDatabase(Fortune::class);
 	}
 	}
 
 
 	public function index() {
 	public function index() {

+ 2 - 0
frameworks/PHP/ubiquity/app/controllers/Json.php

@@ -6,6 +6,8 @@ namespace controllers;
  */
  */
 class Json extends \Ubiquity\controllers\Controller {
 class Json extends \Ubiquity\controllers\Controller {
 
 
+	public function __construct() {}
+
 	public function initialize() {
 	public function initialize() {
 		\Ubiquity\utils\http\UResponse::setContentType('application/json');
 		\Ubiquity\utils\http\UResponse::setContentType('application/json');
 	}
 	}

+ 7 - 5
frameworks/PHP/ubiquity/app/controllers/Plaintext.php

@@ -3,14 +3,16 @@ namespace controllers;
 
 
 /**
 /**
  * Plaintext controller.
  * Plaintext controller.
- **/
+ */
 class Plaintext extends \Ubiquity\controllers\Controller {
 class Plaintext extends \Ubiquity\controllers\Controller {
-	
-	public function initialize(){
-		\Ubiquity\utils\http\UResponse::setContentType('text/plain','utf-8');
+
+	public function __construct() {}
+
+	public function initialize() {
+		\Ubiquity\utils\http\UResponse::setContentType('text/plain', 'utf-8');
 	}
 	}
+
 	public function index() {
 	public function index() {
 		echo 'Hello, World!';
 		echo 'Hello, World!';
 	}
 	}
-
 }
 }

+ 3 - 1
frameworks/PHP/ubiquity/app/controllers/SwooleDb.php

@@ -7,7 +7,9 @@ use models\World;
 /**
 /**
  * Bench controller.
  * Bench controller.
  */
  */
-class SwooleDb extends \Ubiquity\controllers\SimpleViewController {
+class SwooleDb extends \Ubiquity\controllers\Controller {
+
+	public function __construct() {}
 
 
 	public function initialize() {
 	public function initialize() {
 		\Ubiquity\utils\http\UResponse::setContentType('application/json');
 		\Ubiquity\utils\http\UResponse::setContentType('application/json');

+ 3 - 1
frameworks/PHP/ubiquity/app/controllers/WorkerDb.php

@@ -7,7 +7,9 @@ use models\World;
 /**
 /**
  * Bench controller.
  * Bench controller.
  */
  */
-class WorkerDb extends \Ubiquity\controllers\SimpleViewController {
+class WorkerDb extends \Ubiquity\controllers\Controller {
+
+	public function __construct() {}
 
 
 	public function initialize() {
 	public function initialize() {
 		\Ubiquity\utils\http\UResponse::setContentType('application/json');
 		\Ubiquity\utils\http\UResponse::setContentType('application/json');

+ 2 - 2
frameworks/PHP/ubiquity/composer.json

@@ -1,7 +1,7 @@
 {
 {
 	"require" : {
 	"require" : {
-		"php" : "^7.1",
-		"phpmv/ubiquity" : "dev-techempower-benchmarks"
+		"php" : "^7.4",
+		"phpmv/ubiquity" : "dev-master"
 	},
 	},
 	"require-dev" : {
 	"require-dev" : {
 		"monolog/monolog" : "^1.24",
 		"monolog/monolog" : "^1.24",

+ 1 - 1
frameworks/PHP/ubiquity/deploy/conf/php.ini

@@ -1920,4 +1920,4 @@ opcache.preload_user=www-data
 
 
 ; Local Variables:
 ; Local Variables:
 ; tab-width: 4
 ; tab-width: 4
-; End:
+; End:

+ 4 - 3
frameworks/PHP/ubiquity/ubiquity-swoole.dockerfile

@@ -9,7 +9,8 @@ RUN apt-get install -y libpq-dev \
     && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
     && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
     && docker-php-ext-install pdo pdo_pgsql pgsql > /dev/null
     && docker-php-ext-install pdo pdo_pgsql pgsql > /dev/null
 
 
-COPY deploy/conf/php-async.ini /usr/local/etc/php/
+COPY deploy/conf/php-async.ini /usr/local/etc/php/php.ini
+RUN echo "zend_extension=opcache.so" >> /usr/local/etc/php/php.ini
 
 
 ADD ./ /ubiquity
 ADD ./ /ubiquity
 WORKDIR /ubiquity
 WORKDIR /ubiquity
@@ -23,13 +24,13 @@ RUN deploy/run/install-composer.sh
 RUN apt-get update -yqq > /dev/null && \
 RUN apt-get update -yqq > /dev/null && \
     apt-get install -yqq git unzip > /dev/null
     apt-get install -yqq git unzip > /dev/null
 
 
-RUN php composer.phar require phpmv/ubiquity-devtools:dev-techempower-benchmarks phpmv/ubiquity-swoole:dev-techempower-benchmarks --quiet
+RUN php composer.phar require phpmv/ubiquity-devtools:dev-master phpmv/ubiquity-swoole:dev-master --quiet
 
 
 RUN php composer.phar install --optimize-autoloader --classmap-authoritative --no-dev --quiet
 RUN php composer.phar install --optimize-autoloader --classmap-authoritative --no-dev --quiet
 
 
 RUN chmod 777 -R /ubiquity/.ubiquity/*
 RUN chmod 777 -R /ubiquity/.ubiquity/*
 
 
-RUN echo "opcache.preload=/ubiquity/app/config/preloader.script.php" >> /usr/local/etc/php/php-async.ini
+RUN echo "opcache.preload=/ubiquity/app/config/preloader.script.php" >> /usr/local/etc/php/php.ini
 
 
 USER www-data
 USER www-data
 
 

+ 3 - 1
frameworks/PHP/ubiquity/ubiquity-workerman.dockerfile

@@ -27,7 +27,7 @@ RUN deploy/run/install-composer.sh
 RUN apt-get update -yqq > /dev/null && \
 RUN apt-get update -yqq > /dev/null && \
     apt-get install -yqq git unzip > /dev/null
     apt-get install -yqq git unzip > /dev/null
 
 
-RUN php composer.phar require phpmv/ubiquity-devtools:dev-techempower-benchmarks phpmv/ubiquity-workerman:dev-techempower-benchmarks --quiet
+RUN php composer.phar require phpmv/ubiquity-devtools:dev-master phpmv/ubiquity-workerman:dev-master --quiet
 
 
 RUN php composer.phar install --optimize-autoloader --classmap-authoritative --no-dev --quiet
 RUN php composer.phar install --optimize-autoloader --classmap-authoritative --no-dev --quiet
 
 
@@ -35,4 +35,6 @@ RUN chmod 777 -R /ubiquity/.ubiquity/*
 
 
 RUN sed -i "s|'worker'|'pgsql'|g" /ubiquity/app/config/workerServices.php
 RUN sed -i "s|'worker'|'pgsql'|g" /ubiquity/app/config/workerServices.php
 
 
+RUN echo "opcache.preload=/ubiquity/app/config/preloader.script.php" >> /etc/php/7.4/cli/php.ini
+
 CMD /ubiquity/vendor/bin/Ubiquity serve -t=workerman -p=8080 -h=0.0.0.0
 CMD /ubiquity/vendor/bin/Ubiquity serve -t=workerman -p=8080 -h=0.0.0.0