Browse Source

setup the mongo stuff

Kpacha 11 years ago
parent
commit
4b53768342
3 changed files with 22 additions and 0 deletions
  1. 4 0
      php-phalcon/app/config/config.php
  2. 17 0
      php-phalcon/public/index.php
  3. 1 0
      php-phalcon/setup.py

+ 4 - 0
php-phalcon/app/config/config.php

@@ -8,6 +8,10 @@ return new \Phalcon\Config(array(
         'password' => 'benchmarkdbpass',
         'name'     => 'hello_world',
     ),
+    'mongodb'     => array(
+        'url'     => 'mongodb://localhost:27017',
+        'db'      => 'hello_world'
+    ),
     'application' => array(
         'controllersDir' => APP_PATH . '/app/controllers/',
         'modelsDir'      => APP_PATH . '/app/models/',

+ 17 - 0
php-phalcon/public/index.php

@@ -72,6 +72,23 @@ try {
         ));
     });
 
+    // Setting up the mongodb connection
+    $di->set('mongo', function() use ($config) {
+        $mongodbConfig = $config->mongodb;
+        
+        $mongo = new \MongoClient($mongodbConfig->url);
+        return $mongo->{$mongodbConfig->db};
+    });
+    
+    //Registering the collectionManager service
+    $di->set('collectionManager', function() {
+        // Setting a default EventsManager
+        $modelsManager = new Phalcon\Mvc\Collection\Manager();
+        $modelsManager->setEventsManager(new Phalcon\Events\Manager());
+        return $modelsManager;
+
+    }, true);
+
     // Handle the request
     $application = new \Phalcon\Mvc\Application();
     $application->setDI($di);

+ 1 - 0
php-phalcon/setup.py

@@ -6,6 +6,7 @@ from os.path import expanduser
 home = expanduser("~")
 
 def start(args, logfile, errfile):
+  setup_util.replace_text("php-phalcon/app/config/config.php", "mongodb:\/\/.*", "mongodb://" + args.database_host)
   setup_util.replace_text("php-phalcon/app/config/config.php", "localhost", ""+ args.database_host +"")
   setup_util.replace_text("php-phalcon/deploy/nginx.conf", "root .*\/FrameworkBenchmarks", "root " + home + "/FrameworkBenchmarks")