Browse Source

Adding Hamlet/React integration (#4102)

* Adding Hamlet 3
Adding Hamlet 3 / Swoole Integration

* Update Swoole version,
Limit number of processes run by swoole

* Optimize composer autoloader

* Adding hamlet-react integration
vka 6 years ago
parent
commit
c06a3b02f5

+ 23 - 0
frameworks/PHP/hamlet/benchmark_config.json

@@ -46,6 +46,29 @@
       "display_name": "hamlet-swoole",
       "display_name": "hamlet-swoole",
       "notes": "",
       "notes": "",
       "versus": "php"
       "versus": "php"
+    },
+    "react": {
+      "plaintext_url": "/plaintext",
+      "json_url": "/json",
+      "db_url": "/db",
+      "query_url": "/queries?queries=",
+      "fortune_url": "/fortunes",
+      "update_url": "/update?queries=",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Fullstack",
+      "database": "mysql",
+      "framework": "hamlet",
+      "language": "PHP",
+      "flavor": "PHP7",
+      "orm": "micro",
+      "platform": "None",
+      "webserver": "react",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "hamlet-react",
+      "notes": "",
+      "versus": "php"
     }
     }
   }]
   }]
 }
 }

+ 3 - 1
frameworks/PHP/hamlet/composer.json

@@ -1,7 +1,9 @@
 {
 {
   "require": {
   "require": {
     "hamlet/hamlet-core" : "^3",
     "hamlet/hamlet-core" : "^3",
-    "cache/void-adapter": "^1"
+    "cache/void-adapter": "^1",
+    "react/http": "*",
+    "swoft/swoole-ide-helper": "*"
   },
   },
   "autoload": {
   "autoload": {
     "psr-4": {
     "psr-4": {

+ 14 - 0
frameworks/PHP/hamlet/hamlet-react.dockerfile

@@ -0,0 +1,14 @@
+FROM php:7.2
+
+RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
+
+RUN apt-get update && apt-get install -y git unzip
+RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
+
+ADD ./ /hamlet
+WORKDIR /hamlet
+
+RUN chmod -R 777 /hamlet
+RUN composer install --quiet --classmap-authoritative --no-dev
+
+CMD php react.php

+ 1 - 1
frameworks/PHP/hamlet/hamlet-swoole.dockerfile

@@ -16,6 +16,6 @@ ADD ./ /hamlet
 WORKDIR /hamlet
 WORKDIR /hamlet
 
 
 RUN chmod -R 777 /hamlet
 RUN chmod -R 777 /hamlet
-RUN composer update --optimize-autoloader
+RUN composer install --quiet --classmap-authoritative --no-dev
 
 
 CMD sed -i 's|NUMCORES|'"$(nproc)"'|g' swoole.php && php swoole.php
 CMD sed -i 's|NUMCORES|'"$(nproc)"'|g' swoole.php && php swoole.php

+ 1 - 1
frameworks/PHP/hamlet/hamlet.dockerfile

@@ -16,7 +16,7 @@ WORKDIR /php
 
 
 RUN if [ $(nproc) = 2 ]; then sed -i "s|pm.max_children = 2048|pm.max_children = 512|g" /etc/php/7.2/fpm/php-fpm.conf ; fi;
 RUN if [ $(nproc) = 2 ]; then sed -i "s|pm.max_children = 2048|pm.max_children = 512|g" /etc/php/7.2/fpm/php-fpm.conf ; fi;
 
 
-RUN composer install --quiet --optimize-autoloader
+RUN composer install --quiet --classmap-authoritative --no-dev
 
 
 RUN chmod -R 777 /php
 RUN chmod -R 777 /php
 
 

+ 7 - 0
frameworks/PHP/hamlet/react.php

@@ -0,0 +1,7 @@
+<?php
+
+require_once __DIR__ . '/vendor/autoload.php';
+
+\Hamlet\Bootstraps\ReactBootstrap::run('0.0.0.0:8080', function () {
+    return new \Benchmark\Application;
+});