Example #1
0
 public static function config()
 {
     if (!self::$_config) {
         self::$_config = new AppConfig();
         self::$_config->addConfiguration(['/etc/cherryphp/global.json', getenv('HOME') . '/.cherryphp/user.json']);
     }
     return self::$_config;
 }
Example #2
0
 /**
  * Initialize the app
  */
 static function init()
 {
     // Load configuration
     if (is_file('config.php')) {
         self::$_config = (require 'config.php');
     } else {
         throw new Exception('No config.php file found.');
     }
     // Initialize Composer autoloader
     require_once 'vendor/autoload.php';
     // Initialize framework
     self::$_router = Base::instance();
     self::$_router->mset(['AUTOLOAD' => 'app/', 'ESCAPE' => false, 'PACKAGE' => 'alanaktion/gh-issues']);
     self::$_router->mset(self::$_config);
     // Initialize database connection and query builder
     self::$_db = new DB\SQL('mysql:host=' . self::$_config['db']['host'] . ';port=3306;dbname=' . self::$_config['db']['database'], self::$_config['db']['username'], self::$_config['db']['password']);
     // Initialize routes
     require_once 'routes.php';
 }
Example #3
0
File: app.php Project: svlt/back
 /**
  * Initialize the app
  */
 static function init()
 {
     // Load configuration
     if (is_file('config.php')) {
         self::$_config = (require 'config.php');
     } else {
         throw new Exception('No config.php file found.');
     }
     // Initialize Composer autoloader
     require_once 'vendor/autoload.php';
     // Initialize framework
     self::$_router = Base::instance();
     self::$_router->mset(['AUTOLOAD' => 'app/', 'ESCAPE' => false, 'PACKAGE' => 'svlt/back', 'CORS.origin' => '*']);
     // Initialize database connection and query builder
     self::$_qb = new Pixie\Connection('mysql', ['driver' => 'mysql'] + self::$_config['db'], 'QB');
     self::$_db = new SQL(QB::pdo(), 'mysql:host=' . self::$_config['db']['host'] . ';port=3306;dbname=' . self::$_config['db']['database']);
     // Initialize routes
     require_once 'routes.php';
 }
Example #4
0
 public function __construct($config = array())
 {
     //设置
     self::$_config = (require PHPFW_PATH . '/config/common.php');
     if (empty($config)) {
         $config = (require APP_PATH . '/config/common.php');
     }
     //适当处理某些设置的值
     $config['cache_dir'] = strlen($config['cache_dir']) ? rtrim($config['cache_dir'], '/') : APP_PATH . '/cache';
     //保存设置至app类属性
     foreach ((array) $config as $key => $val) {
         self::$_config[$key] = $val;
     }
     //解析controller和action
     if (isset($_GET['r'])) {
         list($ctr, $act) = explode('.', $_GET['r'], 2);
     } else {
         $ctr = $act = null;
     }
     self::$controller = $ctr ? $ctr : self::config('default_controller');
     self::$action = $act ? $act : self::config('default_action');
     date_default_timezone_set(self::config('timezone'));
 }
 public static function setConfig($config)
 {
 	self::$_config = $config;
 }