Init commit

This commit is contained in:
ErickSkrauch
2015-01-28 23:20:29 +03:00
commit 290738377b
9 changed files with 235 additions and 0 deletions

15
config/config.php Normal file
View File

@@ -0,0 +1,15 @@
<?php
return new \Phalcon\Config(array(
'mongo' => array(
'host' => 'localhost',
'port' => 27017,
'username' => '',
'password' => '',
'dbname' => 'ely_skins',
),
'application' => array(
'modelsDir' => __DIR__ . '/../models/',
'baseUri' => '/',
)
));

9
config/loader.php Normal file
View File

@@ -0,0 +1,9 @@
<?php
$loader = new \Phalcon\Loader();
$loader->registerDirs(array(
$config->application->modelsDir
));
$loader->register();

50
config/services.php Normal file
View File

@@ -0,0 +1,50 @@
<?php
use Phalcon\Mvc\View;
use Phalcon\Mvc\Url as UrlResolver;
use Phalcon\DI\FactoryDefault;
$di = new FactoryDefault();
$di->set("view", function () {
$view = new \Phalcon\Mvc\View();
$view->disable();
return $view;
});
/**
* The URL component is used to generate all kind of urls in the application
*/
$di->set("url", function () use ($config) {
$url = new UrlResolver();
$url->setBaseUri($config->application->baseUri);
return $url;
});
$di->set("mongo", function() use ($config) {
if (!$config->mongo->username || !$config->mongo->password) {
$mongo = new MongoClient(
"mongodb://".
$config->mongo->host.":".
$config->mongo->port
);
} else {
$mongo = new MongoClient(
"mongodb://".
$config->mongo->username.":".
$config->mongo->password."@".
$config->mongo->host.":".
$config->mongo->port
);
}
return $mongo->selectDb($config->mongo->dbname);
});
//Registering the collectionManager service
$di->setShared('collectionManager', function() {
$modelsManager = new Phalcon\Mvc\Collection\Manager();
return $modelsManager;
});