当前位置: 首页>>代码示例>>PHP>>正文


PHP Config::instance方法代码示例

本文整理汇总了PHP中app\Config::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::instance方法的具体用法?PHP Config::instance怎么用?PHP Config::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Config的用法示例。


在下文中一共展示了Config::instance方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Подключение шаблонизатора Twig
  */
 public function __construct()
 {
     $config = \App\Config::instance();
     $templates_dir = $config->data['templates']['dir'];
     $loader = new \Twig_Loader_Filesystem($templates_dir);
     $this->twig = new \Twig_Environment($loader);
 }
开发者ID:KnyazkovAlexey,项目名称:php2_homework_Knyazkov,代码行数:10,代码来源:View.php

示例2: __construct

 protected function __construct()
 {
     $config = Config::instance();
     try {
         $this->dbh = $this->getPdoObj($config);
     } catch (\PDOException $e) {
         throw new DbException('Не удалось подключиться к БД ' . '<br>' . $e->getMessage());
     }
 }
开发者ID:eropkinvitaliy,项目名称:PHP-2-profit,代码行数:9,代码来源:Db.php

示例3: __construct

 private function __construct()
 {
     $dbc = Config::instance()['db'];
     $dsn = $dbc->driver . ':host=' . $dbc->host . ';dbname=' . $dbc->dbname . ';charset=' . ($dbc->charset ?? 'utf8');
     try {
         $this->dbh = new \PDO($dsn, $dbc->user, $dbc->password);
         $this->dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
     } catch (\PDOException $e) {
         \App\Notifier::instance()->notify('Database problems!!!', 'Cannot connect to database!!!');
         throw new \App\Exceptions\Db(null, 1, $e);
     }
 }
开发者ID:scorp7mix,项目名称:pr-of-it.php2,代码行数:12,代码来源:Db.php

示例4: __construct

 /** 
  * Установка соединения с БД
  */
 public function __construct()
 {
     $config = \App\Config::instance();
     foreach ($config->data['db'] as $property => $value) {
         ${$property} = $value;
     }
     $dsn = 'mysql:host=' . $host . ';dbname=' . $dbname;
     try {
         $this->dbh = new \PDO($dsn, $username, $password);
     } catch (\PDOException $e) {
         throw new \App\Exceptions\Db('Нет соединения с БД');
     }
 }
开发者ID:KnyazkovAlexey,项目名称:php2_homework_Knyazkov,代码行数:16,代码来源:Db.php

示例5: __construct

 /**
  * Создание объекта подключения к БД
  */
 public function __construct()
 {
     $config = App\Config::instance();
     $param1 = 'mysql:host=' . $config->data['db']['host'] . ';dbname=' . $config->data['db']['dbname'];
     self::$DbName = $config->data['db']['dbname'];
     $param2 = $config->data['db']['login'];
     $param3 = $config->data['db']['pass'];
     try {
         $this->dbh = new \PDO($param1, $param2, $param3);
         //Добавлены атрибуты подключения (режимы выброса исключений)
         $this->dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
     } catch (\PDOException $e) {
         $mailer = new \App\SwMailer();
         $res = $mailer->sendMail('Проблемы БД', 'Потеря соединения с БД', 1);
         $msg = !$res ? 'Неудачная попытка оповещения администратора' : 'Администратор оповещен';
         throw new \App\Exceptions\DB('Некорректные параметры подключения к БД. ' . $msg . ' ');
     }
 }
开发者ID:webmaza75,项目名称:php2,代码行数:21,代码来源:Db.php

示例6: check

<?php

require __DIR__ . '/tests.php';
$config = \App\Config::instance();
/**
 * Check if parameter 'db' exists in config
 */
echo check($config->db, 'Config->db');
/**
 * Check if key 'host' exists in parameter 'db' of config
 */
echo check(isset($config->db['host']), 'Config->db[host]');
开发者ID:scorp7mix,项目名称:pr-of-it.php2,代码行数:12,代码来源:Config.php

示例7: actionTable

 protected function actionTable()
 {
     $funcs = Config::instance()->funcs;
     $table = new AdminDataTable([1, 2, 3, 4, 5], $funcs);
     $table->render1();
     $this->view->render('/admin/table.html', ['data' => $table->data, 'func' => $table->namefunc, 'resource' => \PHP_Timer::resourceUsage()]);
 }
开发者ID:eropkinvitaliy,项目名称:PHP-2-profit,代码行数:7,代码来源:Admin.php

示例8: __construct

 protected function __construct()
 {
     $config = Config::instance();
     $this->dbh = new \PDO($config->data['db']['driver'] . ':host=' . $config->data['db']['host'] . ';dbname=' . $config->data['db']['dbname'], $config->data['db']['user'], $config->data['db']['password']);
 }
开发者ID:eropkinvitaliy,项目名称:PHP-2-profit,代码行数:5,代码来源:Db.php

示例9: __construct

 /** 
  * Получение пути к файлу с логами
  */
 public function __construct()
 {
     $config = \App\Config::instance();
     $this->file = $config->data['log']['file'];
 }
开发者ID:KnyazkovAlexey,项目名称:php2_homework_Knyazkov,代码行数:8,代码来源:Logger.php


注:本文中的app\Config::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。