static public function copy($source, $destination, $recursive = true, $ignoreSystemFiles = true)
    {
        if(!is_readable($source)){
            return false;
        }

        $returnValue = (bool) false;


        // Check for System File
        $basename = basename($source);
        if ($basename[0] === '.' && $ignoreSystemFiles === true) {
            return false;
        }

        // Check for symlinks
        if (is_link($source)) {
            return symlink(readlink($source), $destination);
        }

        // Simple copy for a file
        if (is_file($source)) {
            // get path info of destination.
            $destInfo = pathinfo($destination);
            if (isset($destInfo['dirname']) && ! is_dir($destInfo['dirname'])) {
                if (! mkdir($destInfo['dirname'], 0777, true)) {
                    return false;
                }
            }

            return copy($source, $destination);
        }

        // Make destination directory
        if ($recursive == true) {
            if (! is_dir($destination)) {
                // 0777 is default. See mkdir PHP Official documentation.
                mkdir($destination, 0777, true);
            }

            // Loop through the folder
            $dir = dir($source);
            while (false !== $entry = $dir->read()) {
                // Skip pointers
                if ($entry === '.' || $entry === '..') {
                    continue;
                }

                // Deep copy directories
                self::copy("${source}/${entry}", "${destination}/${entry}", $recursive, $ignoreSystemFiles);
            }

            // Clean up
            $dir->close();
            return true;
        } else {
            return false;
        }


        return (bool) $returnValue;
    }
static public function copy($source, $destination, $recursive = true, $ignoreSystemFiles = true)
    {
        if(!is_readable($source)){
            return false;
        }

        $returnValue = (bool) false;


        // Check for System File
        $basename = basename($source);
        if ($basename[0] === '.' && $ignoreSystemFiles === true) {
            return false;
        }

        // Check for symlinks
        if (is_link($source)) {
            return symlink(readlink($source), $destination);
        }

        // Simple copy for a file
        if (is_file($source)) {
            // get path info of destination.
            $destInfo = pathinfo($destination);
            if (isset($destInfo['dirname']) && ! is_dir($destInfo['dirname'])) {
                if (! mkdir($destInfo['dirname'], 0777, true)) {
                    return false;
                }
            }

            return copy($source, $destination);
        }

        // Make destination directory
        if ($recursive == true) {
            if (! is_dir($destination)) {
                // 0777 is default. See mkdir PHP Official documentation.
                mkdir($destination, 0777, true);
            }

            // Loop through the folder
            $dir = dir($source);
            while (false !== $entry = $dir->read()) {
                // Skip pointers
                if ($entry === '.' || $entry === '..') {
                    continue;
                }

                // Deep copy directories
                self::copy("${source}/${entry}", "${destination}/${entry}", $recursive, $ignoreSystemFiles);
            }

            // Clean up
            $dir->close();
            return true;
        } else {
            return false;
        }


        return (bool) $returnValue;
    }
static public function copy ( $ source , $ destination , $ recursive = true , $ ignoreSystemFiles = true ) { if ( ! is_readable ( $ source ) ) { return false ; } $ returnValue = ( bool ) false ; // Check for System File $ basename = basename ( $ source ) ; if ( $ basename [ 0 ] === '.' && $ ignoreSystemFiles === true ) { return false ; } // Check for symlinks if ( is_link ( $ source ) ) { return symlink ( readlink ( $ source ) , $ destination ) ; } // Simple copy for a file if ( is_file ( $ source ) ) { // get path info of destination. $ destInfo = pathinfo ( $ destination ) ; if ( isset ( $ destInfo [ 'dirname' ] ) && ! is_dir ( $ destInfo [ 'dirname' ] ) ) { if ( ! mkdir ( $ destInfo [ 'dirname' ] , 0777 , true ) ) { return false ; } } return copy ( $ source , $ destination ) ; } // Make destination directory if ( $ recursive == true ) { if ( ! is_dir ( $ destination ) ) { // 0777 is default. See mkdir PHP Official documentation. mkdir ( $ destination , 0777 , true ) ; } // Loop through the folder $ dir = dir ( $ source ) ; while ( false !== $ entry = $ dir -> read ( ) ) { // Skip pointers if ( $ entry === '.' || $ entry === '..' ) { continue ; } // Deep copy directories self :: copy ( "${source}/${entry}" , "${destination}/${entry}" , $ recursive , $ ignoreSystemFiles ) ; } // Clean up $ dir -> close ( ) ; return true ; } else { return false ; } return ( bool ) $ returnValue ; }
Copy a file from source to destination, may be done recursively and may ignore system files

@access public
@author Lionel Lecaque, <lionel@taotesting.com>
@param string source
@param string destination
@param boolean recursive
@param boolean ignoreSystemFiles
@return boolean
Copy a file from source to destination may be done recursively and may ignore system files