Sebpro\ArtisanExt\Commands\ExtEnv::handle PHP Method

handle() public method

Execute the console command.
public handle ( ) : void
return void
    public function handle()
    {
        $old_env = $this->laravel['config']['app.env'];
        $file = base_path('.env');
        if (file_exists($file)) {
            file_put_contents($file, str_replace('ENV=' . $old_env, 'ENV=' . $this->argument('environment'), file_get_contents($file)));
            return $this->info('The environment has been changed ' . 'successfully to: ' . $this->argument('environment'));
        }
        return $this->error('The .env configuration file is missing.');
    }