Esempio n. 1
0
 /**
  * Parses environment file
  */
 protected function parseEnvironmentVariables()
 {
     if ($this->allowOverloading) {
         $this->dotEnv->overload();
     } else {
         $this->dotEnv->load();
     }
 }
 /**
  * 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);
 }
 /**
  * @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();
     }
 }
Esempio n. 4
0
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'));
};
Esempio n. 5
-1
 /**
  * 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));
 }