コード例 #1
0
ファイル: index.php プロジェクト: netstu/vd_ask
 /**
  * Register the services here to make them general or register in the ModuleDefinition to make them module-specific
  */
 protected function _registerServices()
 {
     $config = (include __DIR__ . "/../apps/config/config.php");
     $di = new \Phalcon\DI\FactoryDefault();
     $loader = new \Phalcon\Loader();
     /**
      * We're a registering a set of directories taken from the configuration file
      */
     $loader->registerDirs(array($config->application->libraryDir, $config->application->pluginDir))->register();
     //Registering a router
     $di->set('router', function () {
         $router = new \Phalcon\Mvc\Router();
         $router->setDefaultModule("frontend");
         $router->add('/:controller/:action', array('module' => 'frontend', 'controller' => 1, 'action' => 2));
         $router->add("/cats/index", array('module' => 'frontend', 'controller' => 'categories', 'action' => 'index'));
         $router->add("/cat/:params", array('module' => 'frontend', 'controller' => 'categories', 'action' => 'cat', 'params' => 1));
         $router->add("/ask/:params", array('module' => 'frontend', 'controller' => 'ask', 'action' => 'ask', 'params' => 1));
         $router->add("/admin/:controller/:action/:params", array('module' => 'backend', 'controller' => 1, 'action' => 2, 'params' => 3));
         return $router;
     });
     $di->set('db', function () use($config) {
         $mysql = new \Phalcon\Db\Adapter\Pdo\Mysql(array("host" => $config->database->host, "username" => $config->database->username, "password" => $config->database->password, "dbname" => $config->database->name));
         $mysql->query("set names 'utf8'");
         return $mysql;
     });
     $di->set('volt', function ($view, $di) use($config) {
         $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di);
         $volt->setOptions(array('compiledPath' => $config->volt->path, 'compiledExtension' => $config->volt->extension, 'compiledSeparator' => $config->volt->separator, 'stat' => (bool) $config->volt->stat));
         return $volt;
     });
     //Set the views cache service
     $di->set('viewCache', function () {
         //Cache data for one day by default
         $frontCache = new Phalcon\Cache\Frontend\Output(array("lifetime" => 86400));
         //Memcached connection settings
         $cache = new Phalcon\Cache\Backend\File($frontCache, array("cacheDir" => "../apps/caches/"));
         return $cache;
     });
     /**
      * If the configuration specify the use of metadata adapter use it or use memory otherwise
      */
     $di->set('modelsMetadata', function () use($config) {
         if (isset($config->models->metadata)) {
             $metaDataConfig = $config->models->metadata;
             $metadataAdapter = 'Phalcon\\Mvc\\Model\\Metadata\\' . $metaDataConfig->adapter;
             return new $metadataAdapter();
         } else {
             return new Phalcon\Mvc\Model\Metadata\Memory();
         }
     });
     //Start the session the first time some component request the session service
     $di->set('session', function () {
         $session = new Phalcon\Session\Adapter\Files();
         $session->start();
         return $session;
     });
     $this->setDI($di);
 }
コード例 #2
0
ファイル: index.php プロジェクト: abuelezz/mvc
 /**
  * Register the services here to make them general or register in
  * the ModuleDefinition to make them module-specific.
  */
 protected function _registerServices()
 {
     $loader = new \Phalcon\Loader();
     /**
      * We're a registering a set of directories taken from the configuration file
      */
     /*
     $loader->registerDirs(
             array(
                     __DIR__ . '/../library/',
                     __DIR__ . '/../vendor/',
             )
     )->register();
     */
     // Init a DI
     $di = new \Phalcon\DI\FactoryDefault();
     // Registering a router:
     $defaultModule = self::DEFAULT_MODULE;
     $modules = self::$modules;
     $di->set('router', function () use($defaultModule, $modules) {
         $router = new \Phalcon\Mvc\Router();
         $router->setDefaultModule($defaultModule);
         foreach ($modules as $moduleName => $module) {
             // do not route default module
             if ($defaultModule == $moduleName) {
                 continue;
             }
             $router->add('#^/' . $moduleName . '(|/)$#', array('module' => $moduleName, 'controller' => 'index', 'action' => 'index'));
             $router->add('#^/' . $moduleName . '/([a-zA-Z0-9\\_]+)[/]{0,1}$#', array('module' => $moduleName, 'controller' => 1));
             $router->add('#^/' . $moduleName . '[/]{0,1}([a-zA-Z0-9\\_]+)/([a-zA-Z0-9\\_]+)(/.*)*$#', array('module' => $moduleName, 'controller' => 1, 'action' => 2, 'params' => 3));
         }
         return $router;
     });
     /**
      * The URL component is used to generate all kind of urls in the application
      */
     $di['url'] = function () {
         $url = new \Phalcon\Mvc\Url();
         $url->setBaseUri('/');
         return $url;
     };
     /**
      * Start the session the first time some component request the session service
      */
     $di['session'] = function () {
         $session = new \Phalcon\Session\Adapter\Files();
         $session->start();
         return $session;
     };
     $this->setDI($di);
 }
コード例 #3
0
ファイル: App.php プロジェクト: ddonng/swoole-phalcon
 public static function initSystemService()
 {
     global $di;
     //读取配置项
     $config = (require CONFIG_PATH . "/config.php");
     $di->setShared('config', function () use($config) {
         return $config;
     });
     //设置master数据库
     $di->setShared('dbMaster', function () use($config) {
         return new \Phalcon\Db\Adapter\Pdo\Mysql($config->dbMaster->toArray());
     });
     //设置slave1数据库
     $di->setShared('dbSlave1', function () use($config) {
         return new \Phalcon\Db\Adapter\Pdo\Mysql($config->dbSlave1->toArray());
     });
     //设置slave2数据库
     $di->setShared('dbSlave2', function () use($config) {
         return new \Phalcon\Db\Adapter\Pdo\Mysql($config->dbSlave2->toArray());
     });
     //设置redis缓存
     $di->setShared('redis', function () use($config) {
         $frontCache = new \Phalcon\Cache\Frontend\Data($config->cache_life->toArray());
         return new Phalcon\Cache\Backend\Redis($frontCache, $config->redis->toArray());
     });
     //设置Beanstalk队列
     $di->setShared('queue', function () use($config) {
         return new Phalcon\Queue\Beanstalk($config->beanstalk->toArray());
     });
     //设置session
     $di->setShared('session', function () {
         $session = new \Phalcon\Session\Adapter\Files();
         $session->start();
         return $session;
     });
     //设置router
     $di->set('router', function () {
         $router = new \Phalcon\Mvc\Router();
         $router->setDefaultModule("home");
         $router->add('/:module/:controller/:action', array('module' => 1, 'controller' => 2, 'action' => 3));
         return $router;
     });
 }
コード例 #4
0
ファイル: index.php プロジェクト: abuelezz/mvc
 /**
  * Register the services here to make them general or register in the ModuleDefinition to make them module-specific
  */
 protected function _registerServices()
 {
     $di = new \Phalcon\DI\FactoryDefault();
     $loader = new \Phalcon\Loader();
     /**
      * We're a registering a set of directories taken from the configuration file
      */
     $loader->registerDirs(array(__DIR__ . '/../apps/library/'))->register();
     //Registering a router
     $di->set('router', function () {
         $router = new \Phalcon\Mvc\Router();
         $router->setDefaultModule("frontend");
         $router->add('/:controller/:action', array('module' => 'frontend', 'controller' => 1, 'action' => 2));
         $router->add("/login", array('module' => 'backend', 'controller' => 'login', 'action' => 'index'));
         $router->add("/admin/products/:action", array('module' => 'backend', 'controller' => 'products', 'action' => 1));
         $router->add("/products/:action", array('module' => 'frontend', 'controller' => 'products', 'action' => 1));
         return $router;
     });
     $this->setDI($di);
 }
コード例 #5
0
* @author The Phuc
* @since  06/01/2016
*/
error_reporting(E_ALL);
try {
    /** Define */
    define('BASEURL', 'http://phalcon.dev/');
    define('CACHE_DATA_ADMIN', '../apps/common/caches/admin');
    define('CACHE_DATA_USERS', '../apps/common/caches/users');
    define('ADMIN_INFO', serialize(array('name' => 'Thế Phúc', 'email' => '*****@*****.**', 'mailHost' => 'smtp.gmail.com', 'mailPort' => 587, 'mailPassword' => '----')));
    /** The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework */
    $di = new \Phalcon\DI\FactoryDefault();
    /** Registering a router */
    $di['router'] = function () {
        $router = new \Phalcon\Mvc\Router();
        $router->setDefaultModule('users');
        $router->setDefaultController('index');
        $router->setDefaultAction('index');
        $adminRoutes = glob(dirname(__DIR__) . "/apps/**/routes/*.php");
        foreach ($adminRoutes as $key => $value) {
            require_once $value;
        }
        $router->notFound(array('module' => 'users', 'controller' => 'error', 'action' => 'error404'));
        $router->removeExtraSlashes(true);
        return $router;
    };
    /** The URL component is used to generate all kind of urls in the application */
    $di->set('url', function () {
        $url = new \Phalcon\Mvc\Url();
        $url->setBaseUri('/');
        return $url;
コード例 #6
0
<?php

$router = new Phalcon\Mvc\Router(true);
$router->setDefaultModule("frontend");
$router->removeExtraSlashes(TRUE);
$router->add('/:controller/:action[/]{0,1}', array('module' => 'frontend', 'controller' => 1, 'action' => 2, 'module' => 'frontend', 'namespace' => 'reportingtool\\Modules\\Modules\\Frontend\\Controllers'));
$router->add('/{language:[a-z]{2}}/:controller[/]{0,1}', array('language' => 1, 'controller' => 2, 'action' => "index", 'module' => 'frontend', 'namespace' => 'reportingtool\\Modules\\Modules\\Frontend\\Controllers'));
$router->add('/{language:[a-z]{2}}/:controller/:action[/]{0,1}', array('language' => 1, 'controller' => 2, 'action' => 3, 'module' => 'frontend', 'namespace' => 'reportingtool\\Modules\\Modules\\Frontend\\Controllers'));
$router->add('/{language:[a-z]{2}}/:controller/:action/:int[/]{0,1}', array('language' => 1, 'controller' => 2, 'action' => 3, 'uid' => 4, 'module' => 'frontend', 'namespace' => 'reportingtool\\Modules\\Modules\\Frontend\\Controllers'));
$router->add('/', array('controller' => 'index', 'action' => 'index', 'module' => 'frontend', 'namespace' => 'reportingtool\\Modules\\Modules\\Frontend\\Controllers'));
$router->add('/session/index/', array('controller' => 'session', 'action' => 'index', 'module' => 'frontend', 'namespace' => 'reportingtool\\Modules\\Modules\\Frontend\\Controllers'));
$router->add('/session/start[/]{0,1}', array('controller' => 'session', 'action' => 'start', 'module' => 'frontend', 'namespace' => 'reportingtool\\Modules\\Modules\\Frontend\\Controllers'));
$router->add('/session/logout[/]{0,1}', array('controller' => 'session', 'action' => 'logout', 'module' => 'frontend', 'namespace' => 'reportingtool\\Modules\\Modules\\Frontend\\Controllers'));
$router->add('/backend/{language:[a-z]{2}}/:controller[/]{0,1}', array('language' => 1, 'controller' => 2, 'action' => "index", 'module' => 'backend', 'namespace' => 'reportingtool\\Modules\\Modules\\Backend\\Controllers'));
$router->add('/backend/{language:[a-z]{2}}/:controller/:action[/]{0,1}', array('language' => 1, 'controller' => 2, 'action' => 3, 'module' => 'backend', 'namespace' => 'reportingtool\\Modules\\Modules\\Backend\\Controllers'));
$router->add('/backend/{language:[a-z]{2}}/:controller/:action/:int[/]{0,1}', array('language' => 1, 'controller' => 2, 'action' => 3, 'uid' => 4, 'module' => 'backend', 'namespace' => 'reportingtool\\Modules\\Modules\\Backend\\Controllers'));
$router->add('/backend', array('controller' => 'index', 'action' => 'index', 'module' => 'backend', 'namespace' => 'reportingtool\\Modules\\Modules\\Backend\\Controllers'));
$router->handle();
return $router;
コード例 #7
0
ファイル: index.php プロジェクト: Riu/kirocms
$di->setShared('cookies', function () {
    $cookies = new \Phalcon\Http\Response\Cookies();
    return $cookies;
});
$di->setShared('session', function () {
    $session = new \Phalcon\Session\Adapter\Files();
    $session->start();
    return $session;
});
//Specify routes for modules
$di->setShared('router', function () use($config, $routers) {
    $router = new \Phalcon\Mvc\Router(false);
    $router->clear();
    $router->removeExtraSlashes(true);
    $router->clear();
    $router->setDefaultModule($config->app->defaultApp);
    $router->setDefaultController($config->app->defaultController);
    $router->setDefaultAction($config->app->defaultAction);
    if (!empty($routers)) {
        foreach ($routers as $name => $rule) {
            $pattern = $rule->pattern;
            unset($rule->pattern);
            $router->add($pattern, $rule->toArray())->setName($name);
        }
    }
    return $router;
});
$di->setShared('db', function () use($config) {
    $connection = new \Phalcon\Db\Adapter\Pdo\Mysql(array("host" => $config->database->host, "username" => $config->database->username, "password" => $config->database->password, "dbname" => $config->database->name, "charset" => $config->database->charset, "collation" => $config->database->collation));
    return $connection;
});
コード例 #8
0
ファイル: index.php プロジェクト: ChainBoy/phalcon
<?php

use Phalcon\Mvc\Application;
error_reporting(E_ALL);
ini_set('date.timezone', 'Asia/Shanghai');
try {
    $loader = new \Phalcon\Loader();
    $loader->registerNamespaces(array("Phalcon_wifi\\Common\\Models" => "../apps/Common/models", "Phalcon_wifi\\Common\\Controllers" => "../apps/Common/controllers", "Phalcon_wifi\\Common\\Config" => "../apps/Common/config", "Phalcon_wifi\\Common\\Ext" => "../apps/Common/ext", "Phalcon_wifi\\Common\\Validate" => "../apps/Common/validate"));
    $loader->register();
    $di = new \Phalcon\DI\FactoryDefault();
    $di["router"] = function () {
        $router = new \Phalcon\Mvc\Router();
        $router->setDefaultModule("Admin");
        $router->setDefaultNamespace("Phalcon_wifi\\Admin\\Controllers");
        $router->add('/:controller/:action/:params', array('module' => 'Admin', 'controller' => 1, 'action' => 2, 'params' => 3))->setName("common");
        return $router;
    };
    $di["url"] = function () use($di) {
        $url = new \Phalcon\Mvc\Url();
        $url->setBaseUri($di->get("config")->get("common")["baseuri"]);
        return $url;
    };
    $di["session"] = function () {
        $session = new \Phalcon\Session\Adapter\Files();
        $session->start();
        return $session;
    };
    $di["db"] = function () use($di) {
        $config = $di->get("config")->get("common")["db"];
        $connection = new \Phalcon\Db\Adapter\Pdo\Mysql(array("host" => $config["host"], "username" => $config["username"], "password" => $config["password"], "dbname" => $config["dbname"], "charset" => $config["charset"]));
        $eventsManager = new \Phalcon\Events\Manager();
コード例 #9
0
ファイル: core.php プロジェクト: LWFeng/xnx
// 匹配回调函数(Match Callbacks)
class AjaxFilter
{
    public function check($uri, $route)
    {
        return $_SERVER['HTTP_X_REQUESTED_WITH'] == 'xmlhttprequest';
    }
}
$router->add('...', array())->beforeMatch(array(new AjaxFilter(), 'check'));
// 限制主机名(Hostname Constraints)
$router->add('...', array())->setHostName('admin.company.com');
$router->add('...', array())->setHostName('([a-z+]).company.com');
Phalcon\Mvc\Router\Group::setHostName('blog.mycompany.com');
// 设置默认路径(Setting default paths)
//Setting a specific default
$router->setDefaultModule('backend');
$router->setDefaultNamespace('Backend\\Controllers');
$router->setDefaultController('index');
$router->setDefaultAction('index');
//Using an array
$router->setDefaults(array('controller' => 'index', 'action' => 'index'));
// 处理结尾额外的斜杆(Dealing with extra/trailing slashes)
$router->removeExtraSlashes(true);
// 没有找到路径(Not Found Paths)
$router->notFound(array("controller" => "index", "action" => "route404"));
$router->handle();
$di->set('router', function () {
    require __DIR__ . '/../app/config/routes.php';
    return $router;
});
// *** Url ***
コード例 #10
0
ファイル: services.php プロジェクト: skwear/depot
<?php

namespace Depot;

$di = new \Phalcon\DI\FactoryDefault();
$di->set('router', function () {
    $router = new \Phalcon\Mvc\Router();
    $router->setDefaultModule('cdn');
    $router->removeExtraSlashes(true);
    $router->notFound(array('module' => 'cdn', 'controller' => 'index', 'action' => 'route404'));
    $router->add('/', array('module' => 'cdn', 'controller' => 'index', 'action' => 'index'));
    /*
     * UI
     */
    $router->add('/ui', array('module' => 'ui', 'controller' => 'index', 'action' => 'index'));
    $router->add('/ui/:controller/:action', array('module' => 'ui', 'controller' => 1, 'action' => 2));
    /*
     * Cdn
     */
    $router->add('/{uuid}', array('module' => 'cdn', 'controller' => 'index', 'action' => 'deliver'));
    $router->add('/{uuid}[.]{ext:[a-z]+}', array('module' => 'cdn', 'controller' => 'index', 'action' => 'deliver'));
    $router->add('/{uuid}/-/{operations:.+}', array('module' => 'cdn', 'controller' => 'index', 'action' => 'deliver'));
    $router->add('/{uuid}/-/{operations:.+}[.]{ext:[a-z]+}', array('module' => 'cdn', 'controller' => 'index', 'action' => 'deliver'));
    /*
     * Api
     */
    $router->add('/api/{version:[0-9.]+}/files', array('module' => 'api', 'controller' => 'files', 'action' => 'index'), array('GET'));
    $router->add('/api/{version:[0-9.]+}/files', array('module' => 'api', 'controller' => 'files', 'action' => 'upload'), array('POST', 'PUT'));
    $router->add('/api/{version:[0-9.]+}/files/{uuid}', array('module' => 'api', 'controller' => 'files', 'action' => 'get'), array('GET'));
    $router->add('/api/{version:[0-9.]+}/files/{uuid}', array('module' => 'api', 'controller' => 'files', 'action' => 'edit'), array('POST', 'PUT'));
    $router->add('/api/{version:[0-9.]+}/files/{uuid}', array('module' => 'api', 'controller' => 'files', 'action' => 'delete'), array('DELETE'));
コード例 #11
0
ファイル: default-web.php プロジェクト: luoshulin/falcon
$di->set('crypt', function () {
    $crypt = new Phalcon\Crypt();
    $crypt->setKey('#1dj8$=dp?.ak//j1V$');
    //Use your own key!
    return $crypt;
});
$di->setShared('session', function () {
    $session = new \Phalcon\Session\Adapter\Files();
    $session->start();
    return $session;
});
$di->set('flash', function () {
    $flash = new \Phalcon\Flash\Direct(array('error' => 'alert alert-error', 'success' => 'alert alert-success', 'notice' => 'alert alert-info'));
    return $flash;
});
// register rules for router
$di->setShared('router', function () {
    $router = new \Phalcon\Mvc\Router();
    $router->setDefaultModule("sample");
    $router->add("/:module/:controller/:action/:params", array("module" => 1, "controller" => 2, "action" => 3, "params" => 4));
    $router->add("/goods/:action/:params", array("module" => "sample", "controller" => "goods", "action" => 1, "params" => 2));
    $router->add("/user/:action/:params", array("module" => "sample", "controller" => "user", "action" => 1, "params" => 2));
    $router->add("/wishlist/:action/:params", array("module" => "sample", "controller" => "wishlist", "action" => 1, "params" => 2));
    $router->add("/cart/:action/:params", array("module" => "sample", "controller" => "cart", "action" => 1, "params" => 2));
    $router->add("/comment/:action/:params", array("module" => "sample", "controller" => "comment", "action" => 1, "params" => 2));
    $router->add("/goods/detail-{id:[0-9]+}.html", array("module" => "sample", "controller" => "goods", "action" => "detail"));
    return $router;
});
// register multi-modules
$application->registerModules($config->web_module->toArray());
/* default-web.php ends here */
コード例 #12
0
ファイル: index_test.php プロジェクト: noikiy/public
 //自动加载
 $loader = new \Phalcon\Loader();
 $loader->registerDirs($config->autoload->toArray())->register();
 //依赖注入
 $di = new \Phalcon\DI\FactoryDefault();
 //URL	延迟加载
 $di->set('url', function () use($config) {
     return new \Phalcon\Mvc\Url();
 }, true);
 //路由器		延迟加载
 $di->set('router', function () use($config) {
     $router = new \Phalcon\Mvc\Router();
     //加载默认模块
     $key = $config->modules->default;
     if ($key && $config->modules->{$key}->used == 1) {
         $router->setDefaultModule('frontend');
     }
     return $router;
 }, true);
 //加载视图
 $view = new Phalcon\MVC\View();
 $view->registerEngines(array('.html' => 'Phalcon\\Mvc\\View\\Engine\\Php'));
 $di->set('view', $view);
 //session	延迟加载
 $di->set('session', new Phalcon\Session\Adapter\Files());
 $di->get('session')->start();
 //加载DB负载均衡
 BalanceDb::config($config->balanceDb->toArray());
 foreach ($config->balanceDb->toArray() as $dbKey => $currentConfig) {
     if ($dbKey == 'default') {
         continue;
コード例 #13
0
ファイル: bootstrap.php プロジェクト: sharkodlak/pinek
<?php

$di = new \Phalcon\DI\FactoryDefault();
$di->set('router', function () {
    $router = new \Phalcon\Mvc\Router();
    $router->setDefaultModule('shop');
    $router->add('/:module/:controller/:action/:params', array('module' => 1, 'controller' => 2, 'action' => 3, 'params' => 4));
    return $router;
});
try {
    $application = new \Phalcon\Mvc\Application($di);
    $application->registerModules(array('shop' => array('className' => 'Bishop\\Shop\\Module', 'path' => ROOT_DIR . '/app/shop/Module.php'), 'backend' => array('className' => 'Bishop\\Admin\\Module', 'path' => ROOT_DIR . '/app/admin/Module.php')));
    echo $application->handle()->getContent();
} catch (\Exception $e) {
    echo $e->getMessage();
}
コード例 #14
0
ファイル: router.php プロジェクト: kimthangatm/zcms
<?php

/**
 * Registering a router
 */
$router = new \Phalcon\Mvc\Router(false);
//Set default router
$router->setDefaultModule('index');
$router->setDefaultController('index');
$router->setDefaultAction('index');
/**
 * Frontend router
 */
$router->add('/', ['module' => 'index', 'controller' => 'index', 'action' => 'index']);
//Load router frontend
$router = zcms_load_frontend_router($router);
/**
 * Backend router
 */
$router->add('/admin[/]?', ['module' => 'admin', 'controller' => 'index', 'action' => 'index']);
$router->add('/admin/:module/:controller/:action/:params', ['module' => 1, 'controller' => 2, 'action' => 3, 'params' => 4]);
$router->add('/admin/:module/:controller/:action', ['module' => 1, 'controller' => 2, 'action' => 3]);
$router->add('/admin/:module/:controller[/]?', ['module' => 1, 'controller' => 2, 'action' => 'index']);
$router->add('/admin/:module[/]?', ['module' => 1, 'controller' => 'index', 'action' => 'index']);
//404 not found
$router->notFound(['module' => 'index', 'controller' => 'error', 'action' => 'notFound404']);
return $router;
コード例 #15
-1
ファイル: index.php プロジェクト: viniciusilveira/pluton
 protected function _registerServices()
 {
     $di = new \Phalcon\DI\FactoryDefault();
     $loader = new \Phalcon\Loader();
     $loader->registerDirs(array(FOLDER_PROJECT . '/apps/library/', FOLDER_PROJECT . '/apps/backend/models', FOLDER_PROJECT . '/apps/frontend/models'))->register();
     //usando autoloader do composer para carregar as depêndencias instaladas via composer
     require_once FOLDER_PROJECT . 'vendor/autoload.php';
     $di->set('router', function () {
         $router = new \Phalcon\Mvc\Router();
         $router->setDefaultModule("frontend");
         $router->add('/:controller/:action', array('module' => 'frontend', 'controller' => 1, 'action' => 2));
         $router->add('/:controller/:action', array('module' => 'backend', 'controller' => 1, 'action' => 2));
         $router->add("/admin", array('module' => 'backend', 'controller' => 'index', 'action' => 'index'));
         $router->add("/editor", array('module' => 'frontend', 'controller' => 'index', 'action' => 'index'));
         $router->add("/index/:action", array('controller' => 'index', 'action' => 1));
         return $router;
     });
     $di->set("libMail", function () {
         return new Multiple\Library\Mail();
     });
     /**
      * Caso exista o arquivo de configuração config.ini coleta os dados existentes nele e
      * conecta com o banco de dados
      */
     if (file_exists('../apps/config/config.ini')) {
         $config = new \Phalcon\Config\Adapter\Ini('../apps/config/config.ini');
         //Seta a conexão com o banco de dados
         $di->set('db', function () use($config) {
             $dbclass = 'Phalcon\\Db\\Adapter\\Pdo\\' . $config->database->adapter;
             return new $dbclass(array("host" => $config->database->host, "username" => $config->database->username, "password" => $config->database->password, "dbname" => $config->database->name, "charset" => 'utf8'));
         });
     }
     $this->setDI($di);
 }