Browse Source

upgrade phalcon and phalcon-micro to use phalcon v2 and php7

Keith Newman 9 years ago
parent
commit
f44fb06a04

+ 1 - 1
frameworks/PHP/phalcon-micro/benchmark_config.json

@@ -5,7 +5,7 @@
       "setup_file": "setup",
       "setup_file": "setup",
       "json_url": "/json",
       "json_url": "/json",
       "db_url": "/db",
       "db_url": "/db",
-      "query_url": "/db?queries=",
+      "query_url": "/queries?queries=",
       "fortune_url": "/fortunes",
       "fortune_url": "/fortunes",
       "port": 8080,
       "port": 8080,
       "approach": "Realistic",
       "approach": "Realistic",

+ 15 - 5
frameworks/PHP/phalcon-micro/public/index.php

@@ -8,7 +8,7 @@ try {
     $app['db'] = function() {
     $app['db'] = function() {
 
 
         return new \Phalcon\Db\Adapter\Pdo\Mysql(array(
         return new \Phalcon\Db\Adapter\Pdo\Mysql(array(
-            'dsn'       => 'host=localhost;dbname=hello_world;charset=utf8',
+            'dsn'       => 'host=127.0.0.1;dbname=hello_world;charset=utf8',
             'username'   => 'benchmarkdbuser',
             'username'   => 'benchmarkdbuser',
             'password'   => 'benchmarkdbpass',
             'password'   => 'benchmarkdbpass',
             'persistent' => true
             'persistent' => true
@@ -47,10 +47,24 @@ try {
 
 
     //
     //
     $app->map('/db', function() use ($app) {
     $app->map('/db', function() use ($app) {
+        header("Content-Type: application/json");
+
+        $db = $app['db'];
+        
+        $world = $db->fetchOne('SELECT * FROM world WHERE id = ' . mt_rand(1, 10000), Phalcon\Db::FETCH_ASSOC);
+
+        echo json_encode($world);
+    });
+
+
+    // queries
+    $app->map('/queries', function() use ($app) {
+        header("Content-Type: application/json");
 
 
         $db = $app['db'];
         $db = $app['db'];
 
 
         $queries = $app->request->getQuery('queries', null, 1);
         $queries = $app->request->getQuery('queries', null, 1);
+        $queries = is_numeric($queries) ? min(max(intval($queries), 1), 500) : 1;
 
 
         $worlds = array();
         $worlds = array();
 
 
@@ -58,10 +72,6 @@ try {
             $worlds[] = $db->fetchOne('SELECT * FROM world WHERE id = ' . mt_rand(1, 10000), Phalcon\Db::FETCH_ASSOC);
             $worlds[] = $db->fetchOne('SELECT * FROM world WHERE id = ' . mt_rand(1, 10000), Phalcon\Db::FETCH_ASSOC);
         }
         }
 
 
-        if ($queries == 1) {
-            $worlds = $worlds[0];
-        }
-
         echo json_encode($worlds);
         echo json_encode($worlds);
     });
     });
 
 

+ 1 - 1
frameworks/PHP/phalcon-micro/setup.sh

@@ -1,6 +1,6 @@
 #!/bin/bash
 #!/bin/bash
 
 
-fw_depends php phalcon nginx
+fw_depends php7 phalcon nginx
 
 
 sed -i 's|localhost|'"${DBHOST}"'|g' public/index.php
 sed -i 's|localhost|'"${DBHOST}"'|g' public/index.php
 sed -i 's|root .*/FrameworkBenchmarks/php-phalcon-micro|root '"${TROOT}"'|g' deploy/nginx.conf
 sed -i 's|root .*/FrameworkBenchmarks/php-phalcon-micro|root '"${TROOT}"'|g' deploy/nginx.conf

+ 1 - 1
frameworks/PHP/phalcon/app/controllers/BenchController.php

@@ -71,7 +71,7 @@ class BenchController extends \Phalcon\Mvc\Controller
     {
     {
         $this->view->disable();
         $this->view->disable();
         $this->response->setStatusCode(200, "OK");
         $this->response->setStatusCode(200, "OK");
-        $this->response->setContentType('text/plain', 'UTF-8');
+        $this->response->setContentType('text/plain');
         $this->response->setContent("Hello, World!");
         $this->response->setContent("Hello, World!");
         $this->response->send();
         $this->response->send();
     }
     }

+ 1 - 0
frameworks/PHP/phalcon/benchmark_config.json

@@ -3,6 +3,7 @@
   "tests": [{
   "tests": [{
     "default": {
     "default": {
       "setup_file": "setup",
       "setup_file": "setup",
+      "plaintext_url": "/plaintext",
       "json_url": "/json",
       "json_url": "/json",
       "db_url": "/db",
       "db_url": "/db",
       "query_url": "/queries?queries=",
       "query_url": "/queries?queries=",

+ 1 - 1
frameworks/PHP/phalcon/setup.sh

@@ -1,6 +1,6 @@
 #!/bin/bash
 #!/bin/bash
 
 
-fw_depends php phalcon nginx
+fw_depends php7 phalcon nginx
 
 
 sed -i 's|mongodb://localhost|mongodb://'"${DBHOST}"'|g' app/config/config.php
 sed -i 's|mongodb://localhost|mongodb://'"${DBHOST}"'|g' app/config/config.php
 sed -i 's|localhost|'"${DBHOST}"'|g' app/config/config.php
 sed -i 's|localhost|'"${DBHOST}"'|g' app/config/config.php

+ 3 - 3
toolset/setup/linux/frameworks/phalcon.sh

@@ -10,9 +10,9 @@ RETCODE=$(fw_exists ${IROOT}/phalcon.installed)
 # Enable the PHP phalcon extension
 # Enable the PHP phalcon extension
 sed -i 's|;extension=phalcon.so|extension=phalcon.so|g' $PHP_HOME/lib/php.ini
 sed -i 's|;extension=phalcon.so|extension=phalcon.so|g' $PHP_HOME/lib/php.ini
 
 
-fw_get -O https://github.com/phalcon/cphalcon/archive/phalcon-v1.3.2.tar.gz
-fw_untar phalcon-v1.3.2.tar.gz
-cd cphalcon-phalcon-v1.3.2/build/64bits 
+fw_get -O https://github.com/phalcon/cphalcon/archive/phalcon-v2.0.13.tar.gz
+fw_untar phalcon-v2.0.13.tar.gz
+cd cphalcon-phalcon-v2.0.13/build/64bits 
 $PHP_HOME/bin/phpize
 $PHP_HOME/bin/phpize
 # For some reason we have to point to php-config 
 # For some reason we have to point to php-config 
 # explicitly, it's not found by the prefix settings
 # explicitly, it's not found by the prefix settings