コード例 #1
0
ファイル: ListEnv.php プロジェクト: svenluijten/flex-env
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function handle()
 {
     $env = new Env(base_path('.env'));
     $data = [];
     foreach ($env->all() as $key => $value) {
         $data[] = [$key, $value];
     }
     return $this->table(['Key', 'Value'], $data);
 }
コード例 #2
0
ファイル: GetEnv.php プロジェクト: svenluijten/flex-env
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function handle()
 {
     $env = new Env(base_path('.env'));
     $key = strtoupper($this->argument('key'));
     $result = str_replace('"', '', $env->get($key));
     if ($result == '' || is_null($result)) {
         return $this->error("Could not find a value for [{$key}] in your .env file.");
     }
     return $this->comment("The value for [{$key}] is \"{$result}\".");
 }
コード例 #3
0
ファイル: DeleteEnv.php プロジェクト: svenluijten/flex-env
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function handle()
 {
     $env = new Env(base_path('.env'));
     $key = strtoupper($this->argument('key'));
     $result = $env->delete($key)->get($key);
     if ($result !== '' && !is_null($result)) {
         $env->rollback();
         return $this->comment("No value was found for \"{$key}\" in the .env file, nothing was changed.");
     }
     return $this->comment("Successfully deleted the entry \"{$key}\" from your .env file.");
 }
コード例 #4
0
ファイル: ExampleEnv.php プロジェクト: svenluijten/flex-env
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function handle()
 {
     $env = new Env(base_path('.env'));
     $name = (string) $this->option('name');
     try {
         $env->copy(base_path($name, Env::COPY_FOR_DISTRIBUTION));
         return $this->comment("Successfully created the file [{$name}]");
     } catch (\Exception $e) {
         return $this->error($e->getMessage());
     }
 }
コード例 #5
0
ファイル: SetEnv.php プロジェクト: svenluijten/flex-env
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function handle()
 {
     $env = new Env(base_path('.env'));
     $key = strtoupper($this->argument('key'));
     $value = (string) $this->argument('value');
     $linebreak = (bool) $this->option('line-break');
     if (preg_match('/\\s/', $value)) {
         $value = "\"{$value}\"";
     }
     $result = $env->set($key, $value, $linebreak)->get($key);
     if ($result !== $value) {
         $env->rollback();
         return $this->error('Could not set the value in your .env file, reverting...');
     }
     return $this->comment("Successfully set [{$key}] to [{$value}] in your .env file.");
 }