當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。