Sven\FlexEnv\Env::rollback PHP Méthode

rollback() public méthode

Rolls the .env file back to the way it was before performing the command.
public rollback ( ) : Env
Résultat Env
    public function rollback()
    {
        file_put_contents($this->getPath(), $this->previous);
        return $this;
    }

Usage Example

Exemple #1
0
 /**
  * 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.");
 }
All Usage Examples Of Sven\FlexEnv\Env::rollback