You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Config::get('config')
*/
class Config
{
private static $_config = null;
public static function get($key = null, $default = null)
{
if ($value = self::getConfig()->get($key)) {
return is_object($value) ? $value->toArray() : $value;
} else {
return $default;
}
}
public static function set($key, $value)
{
return self::getConfig()->set($key, $value);
}
public static function getSecret($name = '', $key = null)
{
if ($path = self::getConfig()->get('secret_config_path')) {
$secretConfig = new Yaf_Config_Ini($path, $name);
return $key ? $secretConfig->get($key) : $secretConfig->toArray();
}
}
/获取配置/
private static function getConfig()
{
if (null === self::$_config) {
$config = Application::app()->getConfig()->toArray();
self::$_config = new Config_Simple($config, false);
}
return self::$_config;
}
}
`
Warning: Yaf\Loader::autoload(): You should not use 'Yaf_' as class name prefix in /app/data/application/library/Config.php on line 67
Warning: Yaf\Loader::autoload(): Failed opening script /app/data/application/library/Yaf/Config/Simple.php: No such file or directory in /app/data/application/library/Config.php on line 67
Fatal error: Uncaught Error: Class 'Yaf\Config_Simple' not found in /app/data/application/library/Config.php:67 Stack trace: #0 /app/data/application/library/Config.php(24): Config::getConfig() #1 /app/data/application/library/Log.php(37): Config::get('log.dir') #2 /app/data/application/library/Log.php(20): Log::getStream('INFO') #3 /app/data/application/controllers/Index.php(28): Log::write('log\xE6\xB5\x8B\xE8\xAF\x95', 'INFO') #4 [internal function]: IndexController->indexAction() #5 /app/data/index.php(7): Yaf\Application->run() #6 {main} thrown in /app/data/application/library/Config.php on line 67
The text was updated successfully, but these errors were encountered:
我yaf配置如下
[yaf]
extension=yaf.so
yaf.cache_config=1
yaf.use_namespace=1
根据文档看到
在PHP5.3之后, 打开yaf.use_namespace的情况下, 也可以使用 Yaf\Config_Simple
可是使用时报错
`<?php
use Yaf\Application;
use Yaf\Config_Simple;
/**
对应用配置的封装,方便读取
Config::get('config')
*/
class Config
{
private static $_config = null;
public static function get($key = null, $default = null)
{
if ($value = self::getConfig()->get($key)) {
return is_object($value) ? $value->toArray() : $value;
} else {
return $default;
}
}
public static function set($key, $value)
{
return self::getConfig()->set($key, $value);
}
public static function getSecret($name = '', $key = null)
{
if ($path = self::getConfig()->get('secret_config_path')) {
$secretConfig = new Yaf_Config_Ini($path, $name);
return $key ? $secretConfig->get($key) : $secretConfig->toArray();
}
}
/获取配置/
private static function getConfig()
{
if (null === self::$_config) {
$config = Application::app()->getConfig()->toArray();
self::$_config = new Config_Simple($config, false);
}
return self::$_config;
}
}
`
Warning: Yaf\Loader::autoload(): You should not use 'Yaf_' as class name prefix in /app/data/application/library/Config.php on line 67
Warning: Yaf\Loader::autoload(): Failed opening script /app/data/application/library/Yaf/Config/Simple.php: No such file or directory in /app/data/application/library/Config.php on line 67
Fatal error: Uncaught Error: Class 'Yaf\Config_Simple' not found in /app/data/application/library/Config.php:67 Stack trace: #0 /app/data/application/library/Config.php(24): Config::getConfig() #1 /app/data/application/library/Log.php(37): Config::get('log.dir') #2 /app/data/application/library/Log.php(20): Log::getStream('INFO') #3 /app/data/application/controllers/Index.php(28): Log::write('log\xE6\xB5\x8B\xE8\xAF\x95', 'INFO') #4 [internal function]: IndexController->indexAction() #5 /app/data/index.php(7): Yaf\Application->run() #6 {main} thrown in /app/data/application/library/Config.php on line 67
The text was updated successfully, but these errors were encountered: