本文整理汇总了PHP中Conf::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Conf::set方法的具体用法?PHP Conf::set怎么用?PHP Conf::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Conf
的用法示例。
在下文中一共展示了Conf::set方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSet
public function testSet()
{
$this->conf->set('batch.num.messages', 666);
$dumpedConfig = $this->conf->dump();
$batchNumMessages = $dumpedConfig['batch.num.messages'];
$this->assertEquals(666, $batchNumMessages);
}
示例2: init
static function init()
{
$fh = fopen("./log.txt", "w");
try {
fputs($fh, "start\n");
$conf = new Conf(dirname(__FILE__) . "/../public/conf01.xml");
print "user: " . $conf->get('user') . "\n";
print "host: " . $conf->get('host') . "\n";
$conf->set("pass", "newpass");
$conf->write();
} catch (FileException $e) {
// permissions issue or non-existent file
fputs($fh, "file exception\n");
throw $e;
} catch (XmlException $e) {
fputs($fh, "xml exception\n");
// broken xml
} catch (ConfException $e) {
fputs($fh, "conf exception\n");
// wrong kind of XML file
} catch (Exception $e) {
fputs($fh, "general exception\n");
// backstop: should not be called
} finally {
fputs($fh, "end\n");
fclose($fh);
}
}
示例3: execute
function execute(WebApp $app)
{
// 载入节点数据
require_once API_ROOT . 'StorageExport.php';
$nodes = (new StorageExport())->getNodes();
$curNodeId = Conf::get('node_id');
if (!$curNodeId) {
$curNodeId = isset($_SERVER['STORAGE_NODE_ID']) ? intval($_SERVER['STORAGE_NODE_ID']) : 0;
if ($curNodeId > 0) {
Conf::set('node_id', $curNodeId);
}
}
if (!$curNodeId) {
throw new Exception('node.u_args node_id not defined');
}
// if (!isset($nodes[$curNodeId])) {
// throw new Exception('node.u_curnodeNotFound node_id='.$curNodeId);
// }
Logger::addBasic(array('node_id' => $curNodeId));
$dbConfs = Conf::get('db.conf');
foreach ($nodes as $node) {
// 设定好当前节点的数据库
$cdb = $node['node_db'];
$confs = parse_url($cdb);
if (!isset($confs['port'])) {
$confs['port'] = 3306;
}
$confs['path'] = trim($confs['path'], '/');
$confs['charset'] = 'utf8';
if (isset($confs['query'])) {
parse_str($confs['query'], $args);
if (isset($args['charset']) && $args['charset'] != 'utf8') {
$confs['charset'] = $args['charset'];
}
}
$key = 'node' . $node['node_id'];
$dbConfs['db_pool'][$key] = array('ip' => $confs['host'], 'user' => $confs['user'], 'pass' => $confs['pass'], 'port' => $confs['port'], 'charset' => $confs['charset']);
$dbConfs['dbs'][$key] = $key;
$dbConfs['db_alias'][$key] = $confs['path'];
}
Db::init($dbConfs);
Conf::set('db.conf', $dbConfs);
}
示例4: init
static function init()
{
try {
$config = new Conf("file.xml");
$config->set('sex', 'male');
// назначает значение
$config->write();
// записывает в файл
echo "sex: " . $config->get('sex');
// выводит значение
} catch (FileException $e) {
die($e->__toString());
//файл не существует либо не доступен для записи
} catch (XmlException $e) {
die($e->__toString());
//Повреждённый XML-файл
} catch (ConfException $e) {
die($e->__toString());
//не корректный формат XML-файла
} catch (Exception $e) {
die($e->__toString());
// Этот код не долже никогда вызываться
}
}
示例5: init
static function init()
{
try {
//~ $conf = new Conf( dirname(__FILE__)."/conf.broken.xml" );
//~ $conf = new Conf( dirname(__FILE__)."/conf.unwriteable.xml" );
$conf = new Conf("nonexistent/not_there.xml");
print "user: " . $conf->get('user') . "\n";
print "host: " . $conf->get('host') . "\n";
$conf->set("pass", "newpass");
$conf->write();
} catch (FileException $e) {
// permissions issue or non-existent file
throw $e;
} catch (XmlException $e) {
throw $e;
// broken xml
} catch (ConfException $e) {
throw $e;
// wrong kind of XML file
} catch (Exception $e) {
throw $e;
// backstop: should not be called
}
}
示例6: testInvalidParser
/**
* @expectedException LogicException
*/
public function testInvalidParser()
{
Conf::set('markdown', 'invalid-parser');
App::make('markdown');
}
示例7: write
$this->file = $file;
$this->xml = simplexml_load_file($file);
}
function write()
{
file_put_contents($this->file, $this->xml->asXML());
}
function get($str)
{
$matches = $this->xml->xpath("/conf/item[@name=\"{$str}\"]");
if (count($matches)) {
$this->lastmatch = $matches[0];
return (string) $matches[0];
}
return null;
}
function set($key, $value)
{
if (!is_null($this->get($key))) {
$this->lastmatch[0] = $value;
return;
}
$conf = $this->xml->conf;
$this->xml->addChild('item', $value)->addAttribute('name', $key);
}
}
$conf = new Conf(dirname(__FILE__) . "/conf01.xml");
print "user: " . $conf->get('user') . "\n";
print "host: " . $conf->get('host') . "\n";
$conf->set("pass", "newpass");
$conf->write();
示例8: testSetArray
public function testSetArray()
{
Conf::set(['one' => 'aaa', 'two' => 'bbb']);
$this->assertEquals('aaa', Conf::get('one'));
$this->assertEquals('bbb', Conf::get('two'));
$this->assertEquals('pochika-test', Conf::get('title'));
}
示例9: array
<?php
//路由名字的首尾不加下划线!
Conf::set('route.custom_router', array('login/(:p)' => array('url' => 'login/index', 'p' => array('userid')), 'index/(:p)' => array('url' => 'index/index', 'p' => array('userid')), '(:p)' => array('url' => 'index/index', 'p' => array('userid')), 'search/login/(:p)/new' => array('url' => 'index/index', 'p' => array('userid'))));
示例10: testUnknownAssets
/**
* @expectedException Pochika\Exception\NotFoundException
*/
public function testUnknownAssets()
{
Conf::set('theme', 'unknown');
Artisan::call('pochika:publish_assets');
}
示例11: array
<?php
//全局web配置
//Conf::Set("hihu","hello");
Conf::set('global.view_lib_path', 'core/views/smarty-3.1.27/libs/Smarty.class.php');
Conf::set('global.view_engine', 'Smarty');
Conf::set('global.view_path', APP_ROOT . 'view/views/');
//Conf::set('global.dispatcher_path',PI_CORE.'RouteDispatcher.php');
Conf::set('global.dispatcher_path', PI_CORE . 'RouteDispatcher.php');
Conf::set('global.nolog_exception', array(1022 => 1, 1025 => 1));