public function switchCommand($target = '')
    {
        if ($target === '' && $values = $this->arguments->getValues()) {
            $target = $values[0];
        }

        if ($target === '') {
            $target = $this->arguments->getOption('env');
        }

        $candidates = [];
        foreach ($this->_getEnvTypes() as $file) {
            if (strpos($file, $target) === 0) {
                $candidates[] = $file;
            }
        }

        if (count($candidates) !== 1) {
            return $this->console->error(['can not one file: :env', 'env' => implode(',', $candidates)]);
        }
        $target = $candidates[0];

        $glob = '@root/.env[._-]' . $target;
        $files = $this->filesystem->glob($glob);
        if ($files) {
            $file = $files[0];
            $this->filesystem->fileCopy($file, '@root/.env', true);
            if (file_exists($file . '.php')) {
                $this->filesystem->fileDelete($file . '.php');
            }
            $this->console->writeLn(['copy `:src` to `:dst` success.', 'src' => basename($file), 'dst' => '.env']);
            return 0;
        } else {
            return $this->console->error(['dotenv file `:file` is not exists', 'file' => $glob]);
        }
    }
public function switchCommand($target = '')
    {
        if ($target === '' && $values = $this->arguments->getValues()) {
            $target = $values[0];
        }

        if ($target === '') {
            $target = $this->arguments->getOption('env');
        }

        $candidates = [];
        foreach ($this->_getEnvTypes() as $file) {
            if (strpos($file, $target) === 0) {
                $candidates[] = $file;
            }
        }

        if (count($candidates) !== 1) {
            return $this->console->error(['can not one file: :env', 'env' => implode(',', $candidates)]);
        }
        $target = $candidates[0];

        $glob = '@root/.env[._-]' . $target;
        $files = $this->filesystem->glob($glob);
        if ($files) {
            $file = $files[0];
            $this->filesystem->fileCopy($file, '@root/.env', true);
            if (file_exists($file . '.php')) {
                $this->filesystem->fileDelete($file . '.php');
            }
            $this->console->writeLn(['copy `:src` to `:dst` success.', 'src' => basename($file), 'dst' => '.env']);
            return 0;
        } else {
            return $this->console->error(['dotenv file `:file` is not exists', 'file' => $glob]);
        }
    }
public function switchCommand ( $ target = '' ) { if ( $ target === '' && $ values = $ this -> arguments -> getValues ( ) ) { $ target = $ values [ 0 ] ; } if ( $ target === '' ) { $ target = $ this -> arguments -> getOption ( 'env' ) ; } $ candidates = [ ] ; foreach ( $ this -> _getEnvTypes ( ) as $ file ) { if ( strpos ( $ file , $ target ) === 0 ) { $ candidates [ ] = $ file ; } } if ( count ( $ candidates ) !== 1 ) { return $ this -> console -> error ( [ 'can not one file: :env' , 'env' => implode ( ',' , $ candidates ) ] ) ; } $ target = $ candidates [ 0 ] ; $ glob = '@root/.env[._-]' . $ target ; $ files = $ this -> filesystem -> glob ( $ glob ) ; if ( $ files ) { $ file = $ files [ 0 ] ; $ this -> filesystem -> fileCopy ( $ file , '@root/.env' , true ) ; if ( file_exists ( $ file . '.php' ) ) { $ this -> filesystem -> fileDelete ( $ file . '.php' ) ; } $ this -> console -> writeLn ( [ 'copy `:src` to `:dst` success.' , 'src' => basename ( $ file ) , 'dst' => '.env' ] ) ; return 0 ; } else { return $ this -> console -> error ( [ 'dotenv file `:file` is not exists' , 'file' => $ glob ] ) ; } }
switch .env

@param string $target

@return int
switch . env