public static function copyRecursive($source, $target)
    {
        // handle symlinks
        if (is_link($source)) {
            return symlink(readlink($source), $target);
        }

        // copy a single file
        if (is_file($source)) {
            return copy($source, $target);
        }

        // make target directory
        if (!is_dir($target)) {
            mkdir($target, 0755);
        }

        $handle = opendir($source);
        // loop through the directory
        while (($file = readdir($handle)) !== false) {
            if ($file === '.' || $file === '..') {
                continue;
            }
            $from = $source . DIRECTORY_SEPARATOR . $file;
            $to = $target . DIRECTORY_SEPARATOR . $file;

            if (is_file($from)) {
                copy($from, $to);
            } else {
                // recursive copy
                static::copyRecursive($from, $to);
            }
        }
        closedir($handle);

        return true;
    }