Ver código fonte

Back to MySQLSwooleDatabase (#5195)

* back to MySQLSwooleDatabase

* Adding quiet option back to composer update

* bumping up the number of connections

* bumping up the number of connections

* using pdo with swoole

* Update hamlet-swoole.dockerfile
vka 5 anos atrás
pai
commit
7ccff4ff00

+ 6 - 3
frameworks/PHP/hamlet/hamlet-swoole.dockerfile

@@ -6,8 +6,11 @@ RUN pecl install swoole > /dev/null && \
 RUN docker-php-ext-install mysqli > /dev/null && \
     docker-php-ext-enable mysqli
 
-RUN apt-get update > /dev/null && \
-    apt-get install -y git unzip > /dev/null
+RUN docker-php-ext-install pdo_mysql > /dev/null && \
+    docker-php-ext-enable pdo_mysql
+
+RUN apt-get update -yqq && \
+    apt-get install -yqq git unzip
 
 RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
 
@@ -16,7 +19,7 @@ WORKDIR /php
 RUN chmod -R 777 /php
 
 RUN composer require hamlet-framework/http-swoole:dev-master --quiet
-RUN composer require hamlet-framework/db-mysql-swoole:dev-master --quiet
+RUN composer require hamlet-framework/db-pdo:dev-master --quiet
 RUN composer update --no-dev --quiet
 
 CMD php /php/swoole.php

+ 7 - 3
frameworks/PHP/hamlet/index.php

@@ -1,12 +1,16 @@
 <?php
 
+use Benchmark\Application;
+use Hamlet\Database\MySQL\MySQLDatabase;
+use Hamlet\Http\Bootstraps\ServerBootstrap;
+
 require_once __DIR__ . '/vendor/autoload.php';
 
-$database = new \Hamlet\Database\MySQL\MySQLDatabase(
+$database = new MySQLDatabase(
     'p:tfb-database',
     'benchmarkdbuser',
     'benchmarkdbpass',
     'hello_world'
 );
-$application = new \Benchmark\Application($database);
-\Hamlet\Http\Bootstraps\ServerBootstrap::run($application);
+$application = new Application($database);
+ServerBootstrap::run($application);

+ 9 - 6
frameworks/PHP/hamlet/swoole.php

@@ -1,12 +1,15 @@
 <?php
 
+use Benchmark\Application;
+use Hamlet\Database\PDO\PDODatabase;
+use Hamlet\Http\Swoole\Bootstraps\SwooleBootstrap;
+
 require_once __DIR__ . '/vendor/autoload.php';
 
-$database = new \Hamlet\Database\MySQL\MySQLDatabase(
-    'tfb-database',
+$database = new PDODatabase(
+    'mysql:host=tfb-database;dbname=hello_world',
     'benchmarkdbuser',
-    'benchmarkdbpass',
-    'hello_world'
+    'benchmarkdbpass'
 );
-$application = new \Benchmark\Application($database);
-\Hamlet\Http\Swoole\Bootstraps\SwooleBootstrap::run('0.0.0.0', 8080, $application);
+$application = new Application($database);
+SwooleBootstrap::run('0.0.0.0', 8080, $application);