public static function move($source, $target)
    {
        if (!file_exists($source) || !is_dir($source)) {
            // Rename fails if source folder does not exist.
            throw new \RuntimeException('Cannot move non-existing folder.');
        }

        // Don't do anything if the source is the same as the new target
        if ($source === $target) {
            return;
        }

        if (file_exists($target)) {
            // Rename fails if target folder exists.
            throw new \RuntimeException('Cannot move files to existing folder/file.');
        }

        // Make sure that path to the target exists before moving.
        self::create(dirname($target));

        // Silence warnings (chmod failed etc).
        @rename($source, $target);

        // Rename function can fail while still succeeding, so let's check if the folder exists.
        if (!file_exists($target) || !is_dir($target)) {
            // In some rare cases rename() creates file, not a folder. Get rid of it.
            if (file_exists($target)) {
                @unlink($target);
            }
            // Rename doesn't support moving folders across filesystems. Use copy instead.
            self::copy($source, $target);
            self::delete($source);
        }

        // Make sure that the change will be detected when caching.
        @touch(dirname($source));
        @touch(dirname($target));
        @touch($target);
    }
public static function move($source, $target)
    {
        if (!file_exists($source) || !is_dir($source)) {
            // Rename fails if source folder does not exist.
            throw new \RuntimeException('Cannot move non-existing folder.');
        }

        // Don't do anything if the source is the same as the new target
        if ($source === $target) {
            return;
        }

        if (file_exists($target)) {
            // Rename fails if target folder exists.
            throw new \RuntimeException('Cannot move files to existing folder/file.');
        }

        // Make sure that path to the target exists before moving.
        self::create(dirname($target));

        // Silence warnings (chmod failed etc).
        @rename($source, $target);

        // Rename function can fail while still succeeding, so let's check if the folder exists.
        if (!file_exists($target) || !is_dir($target)) {
            // In some rare cases rename() creates file, not a folder. Get rid of it.
            if (file_exists($target)) {
                @unlink($target);
            }
            // Rename doesn't support moving folders across filesystems. Use copy instead.
            self::copy($source, $target);
            self::delete($source);
        }

        // Make sure that the change will be detected when caching.
        @touch(dirname($source));
        @touch(dirname($target));
        @touch($target);
    }
public static function move ( $ source , $ target ) { if ( ! file_exists ( $ source ) || ! is_dir ( $ source ) ) { // Rename fails if source folder does not exist. throw new \ RuntimeException ( 'Cannot move non-existing folder.' ) ; } // Don't do anything if the source is the same as the new target if ( $ source === $ target ) { return ; } if ( file_exists ( $ target ) ) { // Rename fails if target folder exists. throw new \ RuntimeException ( 'Cannot move files to existing folder/file.' ) ; } // Make sure that path to the target exists before moving. self :: create ( dirname ( $ target ) ) ; // Silence warnings (chmod failed etc). @ rename ( $ source , $ target ) ; // Rename function can fail while still succeeding, so let's check if the folder exists. if ( ! file_exists ( $ target ) || ! is_dir ( $ target ) ) { // In some rare cases rename() creates file, not a folder. Get rid of it. if ( file_exists ( $ target ) ) { @ unlink ( $ target ) ; } // Rename doesn't support moving folders across filesystems. Use copy instead. self :: copy ( $ source , $ target ) ; self :: delete ( $ source ) ; } // Make sure that the change will be detected when caching. @ touch ( dirname ( $ source ) ) ; @ touch ( dirname ( $ target ) ) ; @ touch ( $ target ) ; }
Move directory in filesystem.

@param  string $source
@param  string $target
@throws \RuntimeException
Move directory in filesystem .