作者:riquedesimon
项目:bik
/**
* Registers the module-only services
*
* @param Phalcon\DI $di
*/
public function registerServices($di)
{
/**
* Read configuration
*/
$config = (include __DIR__ . "/config/config.php");
$di['view']->setViewsDir(__DIR__ . '/views/');
/**
* Database connection is created based in the parameters defined in the configuration file
*/
$di['db'] = function () use($config) {
$connection = new DbAdapter(array("host" => $config->database->host, "username" => $config->database->username, "password" => $config->database->password, "dbname" => $config->database->dbname));
$eventsManager = new EventsManager();
$logger = new FileLogger(__DIR__ . "/logs/db.log");
//Listen all the database events
$eventsManager->attach('db:beforeQuery', function ($event, $connection) use($logger) {
$sqlVariables = $connection->getSQLVariables();
if (count($sqlVariables)) {
$logger->log($connection->getSQLStatement() . ' ' . join(', ', $sqlVariables), Logger::INFO);
} else {
$logger->log($connection->getSQLStatement(), Logger::INFO);
}
});
//Assign the eventsManager to the db adapter instance
$connection->setEventsManager($eventsManager);
return $connection;
};
}
作者:ashleykleynhan
项目:fore
/**
* Import Exchange Rates
*/
public function ratesAction()
{
$lock = $this->getLock('/tmp/rates-import.lock');
if ($lock !== false) {
$logger = new FileAdapter(realpath(__DIR__ . '/../logs') . '/rates-import.log');
$di = \Phalcon\DI::getDefault();
$guzzle = $di['guzzle'];
$config = $di['config']['rates_api'];
$url = $config['url'] . '?access_key=' . $config['access_key'] . '¤cies=' . $config['currencies'] . '&source=' . $config['source'];
try {
$request = $guzzle->createRequest('GET', $url);
$response = $guzzle->send($request);
$response = (string) $response->getBody();
$rates = json_decode($response);
if ($rates->success == true) {
foreach ($rates->quotes as $currencyCode => $exchangeRate) {
$currencyCode = preg_replace('/^USD/', '', $currencyCode);
$currency = Rate::updateRate($currencyCode, $exchangeRate);
if (!$currency) {
$logger->log('Failed to update currency : ' . $currencyCode . ' to rate: ' . $exchangeRate, \Phalcon\Logger::ERROR);
}
}
} else {
$logger->log('Rates import failed : ' . $response, \Phalcon\Logger::ERROR);
}
} catch (Exception $e) {
$logger->log('Rates import failed : ' . $e->getMessage(), \Phalcon\Logger::ERROR);
}
$this->releaseLock($lock);
}
}
作者:hongke
项目:Blo
/**
* 保存日志
* @param string $logString 日志信息
* @param string $level 日志级别
*/
public function log($logString, $level = 'info')
{
$logger = new FileLogger($this->logDir . $this->logFile);
$lineFormatter = new LineFormatter();
$lineFormatter->setDateFormat('Y-m-d H:i:s');
$logger->setFormatter($lineFormatter);
$logger->log($logString, $this->log_level[$level]);
}
作者:swordke
项目:phalcon-dem
/**
* Log error to syslog
*
* @param int php error number
* @param string php error description
* @param string php file where the error occured
* @param int php line where the error occured
* @return bool
*/
public static function logToSyslog($errNo, $errStr, $errFile, $errLine)
{
$msg = sprintf("%s (errno: %d) in %s:%d", $errStr, $errNo, $errFile, $errLine);
$logfile = config('config')->logger->path . date('/Ym/') . 'errors_' . date('Ymd') . '.log';
if (!is_dir(dirname($logfile))) {
mkdir(dirname($logfile), 0755, true);
}
$logger = new File($logfile);
return $logger->log($msg, Logger::INFO);
}
作者:vietdh8
项目:product-v
/**
* Registers services related to the module
*
* @param DiInterface $di
*/
public function registerServices(DiInterface $di)
{
/**
* Read configuration
*/
$config = (include APP_PATH . "/apps/backend/config/config.php");
/**
* Setting up the view component
*/
$di['view'] = function () use($config) {
$view = new View();
$view->setViewsDir(__DIR__ . '/views/');
$view->registerEngines(array('.volt' => function ($view, $di) use($config) {
$volt = new VoltEngine($view, $di);
$volt->setOptions(array('compiledPath' => __DIR__ . '/cache/', 'compiledSeparator' => '_'));
$compiler = $volt->getCompiler();
// format number
$compiler->addFilter('number', function ($resolvedArgs) {
return 'Helpers::number(' . $resolvedArgs . ');';
});
return $volt;
}, '.phtml' => 'Phalcon\\Mvc\\View\\Engine\\Php'));
return $view;
};
/**
* Database connection is created based in the parameters defined in the configuration file
*/
$di['db'] = function () use($config) {
$config = $config->database->toArray();
$dbAdapter = '\\Phalcon\\Db\\Adapter\\Pdo\\' . $config['adapter'];
unset($config['adapter']);
return new $dbAdapter($config);
};
/**
* Logger service
*/
$di->set('logger', function ($filename = null, $format = null) use($config) {
$format = $format ?: $config->get('logger')->format;
$filename = trim($filename ?: $config->get('logger')->filename, '\\/');
$path = rtrim($config->get('logger')->path, '\\/') . DIRECTORY_SEPARATOR;
$formatter = new FormatterLine($format, $config->get('logger')->date);
$logger = new FileLogger($path . $filename);
$logger->setFormatter($formatter);
$logger->setLogLevel($config->get('logger')->logLevel);
return $logger;
});
$di->set('url', function () use($config) {
$url = new UrlResolver();
$url->setBaseUri("/backend/");
return $url;
});
}
作者:byhb
项目:napthe-baoki
/**
* Handle post data
*
* @return type
*/
public function handleCardSubmitAction()
{
$seri = $this->request->getPost('txtseri');
$sopin = $this->request->getPost('txtpin');
$mang = $this->request->getPost('chonmang');
$user = $this->request->getPost('txtuser');
$charid = $this->request->getPost('charguid');
$chargeDescription = $this->request->getPost('txtDescription');
if ($mang == 'MOBI') {
$ten = "Mobifone";
} else {
if ($mang == 'VIETEL') {
$ten = "Viettel";
} else {
if ($mang == 'GATE') {
$ten = "Gate";
} else {
if ($mang == 'VTC') {
$ten = "VTC";
} else {
$ten = "Vinaphone";
}
}
}
}
$arrayPost = array('merchant_id' => $this->config->baokim->merchant_id, 'api_username' => $this->config->baokim->api_username, 'api_password' => $this->config->baokim->api_password, 'transaction_id' => time(), 'card_id' => $mang, 'pin_field' => $sopin, 'seri_field' => $seri, 'algo_mode' => 'hmac');
// Prepare array post for CURL
ksort($arrayPost);
//mat khau di kem ma website dang kí trên B?o Kim
$secure_code = $this->config->baokim->secure_code;
$data_sign = hash_hmac('SHA1', implode('', $arrayPost), $secure_code);
$arrayPost['data_sign'] = $data_sign;
$userPwd = $this->config->baokim->CORE_API_HTTP_USR . ':' . $this->config->baokim->CORE_API_HTTP_PWD;
// Init curl
$curl = curl_init($this->config->baokim->restUrl);
curl_setopt_array($curl, array(CURLOPT_POST => true, CURLOPT_HEADER => false, CURLINFO_HEADER_OUT => true, CURLOPT_TIMEOUT => 30, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_HTTPAUTH => CURLAUTH_DIGEST | CURLAUTH_BASIC, CURLOPT_USERPWD => $userPwd, CURLOPT_POSTFIELDS => http_build_query($arrayPost)));
$data = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$result = json_decode($data, true);
$logger = new FileAdapter($this->config->application->logFile);
// if ($status == 200) {
if ($status == 401) {
$logger->log("This is a message");
return $this->response->redirect('index/success');
} else {
$errorData = sprintf("Eror: %d | User: %s | Ma The: %s | Seri: %s", $status, $user, $seri, $sopin);
$logger->error($errorData);
return $this->response->redirect('index');
}
}
作者:lison
项目:cphalco
/**
* Tests new format logs correctly
*
* @author Nikos Dimopoulos <nikos@phalconphp.com>
* @since 2012-09-17
*/
public function testLoggerFormatterNewFormatFormatsDateCorrectly()
{
$fileName = newFileName('log', 'log');
$logger = new PhTLoggerAdapterFile($this->logPath . $fileName);
$formatter = new PhLoggerFormatterLine('%type%|%date%|%message%');
$logger->setFormatter($formatter);
$logger->log('Hello');
$logger->close();
$contents = file($this->logPath . $fileName);
$message = explode('|', $contents[0]);
cleanFile($this->logPath, $fileName);
$date = new \DateTime($message[1]);
$expected = date('Y-m-d H');
$actual = $date->format('Y-m-d H');
$this->assertEquals($expected, $actual, 'Date format not set properly');
}
作者:abc2001
项目:time
public function initPersistentDB($di)
{
// Setup the database service
$di->set('db', function () {
$eventsManager = new EventsManager();
$logger = new FileLogger(__DIR__ . '/' . date('Y-m-d') . '.sql.log');
$eventsManager->attach('db', function ($event, $connection) use($logger) {
if ($event->getType() == 'beforeQuery') {
$logger->info($connection->getSQLStatement());
}
});
$db = new \Phalcon\Db\Adapter\Pdo\Mysql(array("host" => "127.0.0.1", "username" => "root", "password" => "123456", "dbname" => "rookie", "charset" => "utf8", "persistent" => true));
$db->setEventsManager($eventsManager);
return $db;
});
}
作者:phalco
项目:cphalco
/**
* Tests new format logs correctly
*
* @author Nikos Dimopoulos <nikos@phalconphp.com>
* @since 2012-09-17
*/
public function testLoggerFormatterLineNewFormatLogsCorrectly()
{
$this->specify("Line formatted does not set format correctly", function () {
$I = $this->tester;
$fileName = $I->getNewFileName('log', 'log');
$logger = new File($this->logPath . $fileName);
$formatter = new Line('%type%|%date%|%message%');
$logger->setFormatter($formatter);
$logger->log('Hello');
$logger->close();
$I->amInPath($this->logPath);
$I->openFile($fileName);
$I->seeInThisFile(sprintf('DEBUG|%s|Hello', date('D, d M y H:i:s O')));
$I->deleteFile($fileName);
});
}
作者:lison
项目:cphalco
/**
* Tests the begin/rollback
*
* @author Nikolaos Dimopoulos <nikos@phalconphp.com>
* @since 2014-09-13
*/
public function testLoggerAdapterFileRollback()
{
$this->specify("Logging does not contain correct number of messages before rollback", function () {
$fileName = newFileName('log', 'log');
$logger = new PhTLoggerAdapterFile($this->logPath . $fileName);
$logger->log('Hello');
$logger->close();
$contents = file($this->logPath . $fileName);
cleanFile($this->logPath, $fileName);
$expected = 1;
$actual = count($contents);
expect($actual)->equals($expected);
});
$this->specify("Logging does not contain correct number of messages after rollback", function () {
$fileName = newFileName('log', 'log');
$logger = new PhTLoggerAdapterFile($this->logPath . $fileName);
$logger->log('Hello');
$logger->begin();
$logger->log('Message 1');
$logger->log('Message 2');
$logger->log('Message 3');
$logger->rollback();
$logger->close();
$contents = file($this->logPath . $fileName);
cleanFile($this->logPath, $fileName);
$expected = 1;
$actual = count($contents);
expect($actual)->equals($expected);
});
}
作者:kellian
项目:TestZill
/**
* This action is executed before execute any action in the application
* @param Event $event
* @param Dispatcher $dispatcher
*/
public function beforeException(Event $event, MvcDispatcher $dispatcher, Exception $exception)
{
if ($exception instanceof DispatcherException) {
switch ($exception->getCode()) {
case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
$dispatcher->forward(array('controller' => 'errors', 'action' => 'resourceNotFound'));
return false;
}
}
$logDir = $this->config->application->logDir;
$logger = new FileAdapter(APP_PATH . "/{$logDir}/TestZilla.log");
$logger->log($exception->getMessage(), Logger::ERROR);
$logger->log($exception->getTraceAsString(), Logger::ERROR);
$dispatcher->forward(array('controller' => 'errors', 'action' => 'internalServerError'));
return false;
}
作者:phwoolco
项目:phwoolco
public static function register(Di $di)
{
static::$hostname = gethostname();
$di->remove('log');
static::$logger = null;
$di->setShared('log', function () {
$filePath = storagePath('logs');
is_dir($filePath) or mkdir($filePath, 0777, true);
$filePath .= '/' . Config::get('app.log.file', 'phwoolcon.log');
$logger = new File($filePath);
$formatter = $logger->getFormatter();
if ($formatter instanceof Line) {
$formatter->setDateFormat('Y-m-d H:i:s');
$formatter->setFormat('[%date%]{host}[%type%] {request} %message%');
}
return $logger;
});
}
作者:q-phalco
项目:kerne
/**
* 记录起始请求日志
* 记录成功返回true,失败或没记录日志返回false
*
* @return bool
*/
public static function request_start_log()
{
if (!BaseLog::isLog('debug')) {
return false;
}
if (!Config::getEnv("app.request_start_log")) {
return false;
}
$data = Request::nonPostParam();
if (Config::getEnv("app.request_log_post")) {
$data = Request::param();
}
$file_path = BaseLog::handle_log_file('framework', 'debug');
$log_time = date("Y-m-d H:i:s", QP_RUN_START);
$ip = Request::getIp();
$router_url = \Qp\Kernel\Http\Router\QpRouter::getRouterStr();
$prefix = "[{$log_time}] [{$ip}] [router : {$router_url}] ";
$msg = "【请求日志】" . json_encode(['data' => $data]);
$logger = new FileAdapter($file_path);
$logger->setFormatter(new LineFormatter("%message%"));
return (bool) $logger->log($prefix . $msg);
}
作者:jein
项目:Phalcon-RestAp
private function setDB()
{
$connection = new DatabaseConnection($this->database->toArray());
$debug = $this->application->debug;
if ($debug) {
$eventsManager = new EventsManager();
$logger = new FileLogger(__DIR__ . "/../Logs/db.log");
//Listen all the database events
$eventsManager->attach('db', function ($event, $connection) use($logger) {
if ($event->getType() == 'beforeQuery') {
$variables = $connection->getSQLVariables();
if ($variables) {
$logger->log($connection->getSQLStatement() . ' [' . join(',', $variables) . ']', \Phalcon\Logger::INFO);
} else {
$logger->log($connection->getSQLStatement(), \Phalcon\Logger::INFO);
}
}
});
$connection->setEventsManager($eventsManager);
}
return $connection;
}
作者:xxtim
项目:phalco
public function initialize()
{
$this->_app = $this->dispatcher->getParam("app");
// 设置时区
ini_set("date.timezone", $this->config->setting->timezone);
// 日志记录
if ($this->config->setting->recordRequest) {
if (isset($_REQUEST['_url'])) {
$_url = $_REQUEST['_url'];
unset($_REQUEST['_url']);
} else {
$_url = '/';
}
$log = empty($_REQUEST) ? $_url : $_url . '?' . urldecode(http_build_query($_REQUEST));
$logger = new FileLogger(BASE_DIR . $this->config->application->logsDir . date("Ym") . '.log');
$logger->log($log, Logger::INFO);
}
// 检查登录
$this->_user_id = $this->session->get('user_id');
if (!$this->_user_id || !$this->session->get('isLogin')) {
header('Location:/login');
exit;
}
}
作者:simple-helper
项目:php-github-api-wra
$url->setStaticBaseUri($config->application->production->staticBaseUri);
} else {
$url->setBaseUri($config->application->development->baseUri);
$url->setStaticBaseUri($config->application->development->staticBaseUri);
}
return $url;
}, true);
/**
* Database connection is created based in the parameters defined in the configuration file
*/
$di->set('db', function () use($config) {
$connection = new DatabaseConnection($config->database->toArray());
$debug = $config->application->debug;
if ($debug) {
$eventsManager = new EventsManager();
$logger = new FileLogger(APP_PATH . "/app/logs/db.log");
//Listen all the database events
$eventsManager->attach('db', function ($event, $connection) use($logger) {
/** @var Phalcon\Events\Event $event */
if ($event->getType() == 'beforeQuery') {
/** @var DatabaseConnection $connection */
$variables = $connection->getSQLVariables();
if ($variables) {
$logger->log($connection->getSQLStatement() . ' [' . join(',', $variables) . ']', \Phalcon\Logger::INFO);
} else {
$logger->log($connection->getSQLStatement(), \Phalcon\Logger::INFO);
}
}
});
//Assign the eventsManager to the db adapter instance
$connection->setEventsManager($eventsManager);
作者:lookingatsk
项目:zhonghewanban
/**
* 邮件发送
* @param $toemail 收件人
* @param $subject 发件标题
* @param $email_message 发件内容
* <code>
* $mail = new \App\Plugin\Mail();
* $mail->smtp('2483175666@qq.com','Have a try','This is test content');
* </code>
*/
public function smtp($toemail, $subject, $email_message)
{
$email_from = '=?utf-8?B?' . base64_encode($this->sitename) . "?= <" . $this->mail_from . ">";
$email_subject = '=?utf-8?B?' . base64_encode(preg_replace("/[\r|\n]/", '', '[' . $this->sitename . '] ' . $subject)) . '?=';
$headers = "From: {$email_from} \r\nX-Priority: 3 \r\n X-Mailer: Chairsma \r\n MIME-Version: 1.0 \r\n Content-type: text/html\r\n charset=utf-8 \r\n Content-Transfer-Encoding: base64 \r\n ";
$log = new FileAdapter(LOGS_PATH . 'mail_' . date('Ymd') . '.log');
if (!($fp = pfsockopen($this->smtp_server, $this->smtp_port, $errno, $errstr, 30))) {
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ') CONNECT - Unable to connect to the SMTP server');
return false;
}
stream_set_blocking($fp, true);
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != '220') {
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ") CONNECT - {$lastmessage}");
return false;
}
fputs($fp, "HELO Charisma\r\n");
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != 220 && substr($lastmessage, 0, 3) != 250) {
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ") Charisma - {$lastmessage}");
return false;
}
while (1) {
if (substr($lastmessage, 3, 1) != '-' || empty($lastmessage)) {
break;
}
$lastmessage = fgets($fp, 512);
}
fputs($fp, "AUTH LOGIN\r\n");
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != 334) {
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ") AUTH LOGIN - {$lastmessage}");
return false;
}
fputs($fp, base64_encode($this->mail_user) . "\r\n");
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != 334) {
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ") USERNAME - {$lastmessage}");
return false;
}
fputs($fp, base64_encode($this->mail_password) . "\r\n");
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != 235) {
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ") PASSWORD - {$lastmessage}");
return false;
}
fputs($fp, "MAIL FROM: <" . preg_replace("/.*\\<(.+?)\\>.*/", "\\1", $email_from) . ">\r\n");
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != 250) {
fputs($fp, "MAIL FROM: <" . preg_replace("/.*\\<(.+?)\\>.*/", "\\1", $email_from) . ">\r\n");
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != 250) {
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ") MAIL FROM - {$lastmessage}");
return false;
}
}
fputs($fp, "RCPT TO: <" . preg_replace("/.*\\<(.+?)\\>.*/", "\\1", $toemail) . ">\r\n");
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != 250) {
fputs($fp, "RCPT TO: <" . preg_replace("/.*\\<(.+?)\\>.*/", "\\1", $toemail) . ">\r\n");
$lastmessage = fgets($fp, 512);
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ") RCPT TO - {$lastmessage}");
return false;
}
fputs($fp, "DATA\r\n");
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != 354) {
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ") DATA - {$lastmessage}");
return false;
}
fputs($fp, "Date: " . gmdate('r') . "\r\n");
$info = "\r\n发送时间:" . date('Y-m-d H:i:s') . "\r\n";
$info .= '发件人:' . $this->mail_from . "\r\n";
fputs($fp, "To: " . $toemail . "\r\n");
$info .= '收件人:' . $toemail . "\r\n";
fputs($fp, "Subject: " . $email_subject . "\r\n");
$info .= '标题:' . $subject . "\r\n";
fputs($fp, $headers);
fputs($fp, "\r\n\r\n");
fputs($fp, $email_message . "\r\n.\r\n");
$info .= '内容:' . $email_message . "\r\n";
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != 250) {
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ") END - {$lastmessage}");
}
fputs($fp, "QUIT\r\n");
$log->log($info);
return true;
}
作者:vnlit
项目:phalcon-angular-harryhogfootbal
/**
* Initializes the logger
*
* @param array $options
*/
protected function initLogger($options = array())
{
$config = $this->_di->get('config');
$this->_di->set('logger', function () use($config) {
$logger = new PhLoggerFile(ROOT_PATH . $config->app->logger->file);
$formatter = new PhLoggerFormatter($config->app->logger->format);
$logger->setFormatter($formatter);
return $logger;
});
}
作者:vietdh8
项目:vh-utilit
return new Flash(array('error' => 'alert alert-danger', 'success' => 'alert alert-success', 'notice' => 'alert alert-info', 'warning' => 'alert alert-warning'));
});
/**
* Start the session the first time some component request the session service
*/
$di->setShared('session', function () {
$session = new SessionAdapter();
$session->start();
return $session;
});
/*
* Routes
*/
#$di->set('router', function(){
# require 'routes.php';
# return $router;
#});
/**
* Logger service
*/
$di->set('logger', function ($filename = null, $format = null) use($config) {
$format = $format ?: $config->get('logger')->format;
$filename = trim($filename ?: $config->get('logger')->filename, '\\/');
$path = rtrim($config->get('logger')->path, '\\/') . DIRECTORY_SEPARATOR;
#$path = "/temp/system.log";
$formatter = new FormatterLine($format, $config->get('logger')->date);
$logger = new FileLogger($path . $filename);
$logger->setFormatter($formatter);
$logger->setLogLevel($config->get('logger')->logLevel);
return $logger;
});
作者:JanOschi
项目:webir
$gettext = new Gettext();
$gettext->setOptions(['compileAlways' => $compileAlways, 'locale' => $locale->getBestLocale(), 'supported' => $locale->getSupportedLocales(), 'domains' => $config->locale->domains, 'localeDir' => $config->path->localeDir, 'localeCacheDir' => $config->path->localeCacheDir]);
return $gettext;
});
/**
*
*/
$di->setShared('debug', function () use($di) {
$config = $di->getConfig();
$logger = new MultipleStreamLogger();
switch (ENV) {
case DEV_ENV:
$logger->push(new ErrorLogger());
if ('cli' != php_sapi_name()) {
$debugLogFile = str_replace('{{name}}', $config->site->domains[0], $config->dev->path->debugLog);
$fileLogger = new FileLogger($debugLogFile);
$fileLogger->getFormatter()->setFormat('%message%');
$logger->push($fileLogger);
$logger->push(new Firelogger());
$logger->push(new FirephpLogger(''));
}
break;
}
return $logger;
});
/**
* Mail service
*/
$di->setShared('mailer', function () use($di) {
$config = $di->get('config');
$mailManager = new MailManager($config->mailer, $config->site->mail);