mirror of
https://github.com/elyby/chrly.git
synced 2025-05-31 14:11:51 +05:30
Init commit
This commit is contained in:
15
config/config.php
Normal file
15
config/config.php
Normal 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
9
config/loader.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
$loader = new \Phalcon\Loader();
|
||||
|
||||
$loader->registerDirs(array(
|
||||
$config->application->modelsDir
|
||||
));
|
||||
|
||||
$loader->register();
|
||||
50
config/services.php
Normal file
50
config/services.php
Normal 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;
|
||||
});
|
||||
Reference in New Issue
Block a user