thesmart/environment 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

thesmart/environment

Composer 安装命令:

composer require thesmart/environment

包简介

Easily manage database connection strings or other configuration data that changes across server environments such a dev and prod.

README 文档

README

Easily manage database connection strings or other configuration data that changes across server environments such a dev and prod.

Example

This runs one time at the start of your void main:

// construct an instance
new Env('dev');

// development http server url
Env::set('url', array(
	'scheme' => isset($_SERVER) && isset($_SERVER['HTTPS']) ? 'https' : 'http',
	'domain' => 'dev-github.com'
));

// development memcached server connection strings
Env::set('memached.main', array(
	'port' => 11211,
	'addr' => '127.0.0.1'
));

// alternative syntax
Env::set('facebook.appId', '012345678');
Env::set('facebook.secret', '000000000000000000000000000000'); // keep secret
Env::set('facebook.namespace', 'app_name_space');
Env::set('facebook.url', 'https://apps.facebook.com/app_name_space');

Later, you can easily access current environment variables:

// access using dot-notation
$facebookConfig = Env::get('facebook');

$memcached = new \Memcached();
$memcached->addServer(Env::get('memcached.main.addr'), Env::get('memcached.main.port'));

if (Env::has('memcached')) {
	// go cache some shit
}

Mix with OS environment variables to define which configuration to use:

$configToSet	= isset($_SERVER['conf']) ? $_SERVER['conf'] : 'prod';
require_once PATH_CONFIG . $configToSet . '.php';

Like this project?

Check out my others. @thesmart

统计信息

  • 总下载量: 23
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-07-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固