本文整理汇总了PHP中Dotenv\Dotenv::overload方法的典型用法代码示例。如果您正苦于以下问题:PHP Dotenv::overload方法的具体用法?PHP Dotenv::overload怎么用?PHP Dotenv::overload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dotenv\Dotenv
的用法示例。
在下文中一共展示了Dotenv::overload方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseEnvironmentVariables
/**
* Parses environment file
*/
protected function parseEnvironmentVariables()
{
if ($this->allowOverloading) {
$this->dotEnv->overload();
} else {
$this->dotEnv->load();
}
}
示例2: __invoke
/**
* Update wp-cli.yml with settings from .env files
*
* ## OPTIONS
*
* <environment>
* : The name of the environment to set. Typically matched by a .env-<environemnt> file in the project root
*
* @param $args
* @param $assocArgs
*
* @when before_wp_load
*/
public function __invoke($args, $assocArgs)
{
$environment = $args[0];
if (file_exists(WPBOOT_BASEPATH . "/.env")) {
$dotEnv = new Dotenv(WPBOOT_BASEPATH);
$dotEnv->load();
}
$file = '.env-' . $environment;
if (file_exists(WPBOOT_BASEPATH . "/{$file}")) {
$dotEnv = new Dotenv(WPBOOT_BASEPATH, $file);
$dotEnv->overload();
}
try {
$dotEnv = new Dotenv(__DIR__);
$dotEnv->required('wppath');
} catch (\Exception $e) {
echo $e->getMessage() . "\n";
return;
}
$runner = WP_CLI::get_runner();
$ymlPath = $runner->project_config_path;
$yaml = new Yaml();
$config = $yaml->parse(file_get_contents($ymlPath));
$config['path'] = $_ENV['wppath'];
$config['environment'] = $environment;
$dumper = new Dumper();
file_put_contents($ymlPath, $dumper->dump($config, 2));
}
示例3: register
/**
* Add the configuration from the environment to a container
*
* @param Container $container The container
* @param string $alias An optional alias, defaults to 'config'
*
* @return void
*/
public function register(Container $container, $alias = 'config')
{
$file = '.env';
if ($container->has('ConfigFileName')) {
$file = $container->get('ConfigFileName');
}
$dotenv = new Dotenv($container->get('ConfigDirectory'), $file);
$dotenv->overload();
$container->set($alias, new Registry($_ENV), true);
}
示例4: readDotEnv
/**
* @param Container $pimple
*/
private function readDotEnv(Container $pimple)
{
if (file_exists(WPBOOT_BASEPATH . "/.env")) {
$dotEnv = new Dotenv(WPBOOT_BASEPATH);
$dotEnv->load();
}
$file = '.env-' . $pimple['environment'];
if (file_exists(WPBOOT_BASEPATH . "/{$file}")) {
$dotEnv = new Dotenv(WPBOOT_BASEPATH, $file);
$dotEnv->overload();
}
}
示例5: Forge
use Dotenv\Dotenv;
use Og\Kernel\Kernel;
include 'paths.php';
include SUPPORT . 'helpers.php';
include SUPPORT . 'messages.php';
include VENDOR . 'autoload.php';
/** @noinspection PhpUnusedLocalVariableInspection */
$forge = new Forge(new \Illuminate\Container\Container());
// register the Config
$forge->add(['config', Config::class], Config::createFromFolder(CONFIG));
// register the Kernel
$forge->singleton(['kernel', Kernel::class], new Kernel($forge));
// set the timezone (as required by earlier versions of PHP before 7.0.0
date_default_timezone_set($forge['config']['app.timezone']);
# load environment as a requirement
if (file_exists(ROOT . '.env')) {
$dotenv = new Dotenv(ROOT);
$dotenv->overload();
} else {
throw new \LogicException('Unable to find root environment file. Did you remember to rename `.env-example?');
}
# install Tracy if in DEBUG mode
if (strtolower(getenv('DEBUG')) === 'true') {
# core debug utilities
# note that debug requires that the environment has been loaded
include 'debug.php';
}
// register the application instance
$forge['app'] = function () use($forge) {
return new Application($forge->make('kernel'));
};