title: Recursive copy directories
body: <p>I have a function for recursive copy directories. But I'm getting error:</p>
  
  <pre><code>Fatal error: Uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct(/temp/install_5630013a79723/site, /temp/install_5630013a79723/site): The system cannot find the file specified. (code: 2)'
  
  public static function copyDir($source, $dest) {
  
              @mkdir($dest, 0755);
              foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS),  \RecursiveIteratorIterator::SELF_FIRST) as $item) {
                if ($item-&gt;isDir()) {
                  @mkdir($dest . DIRECTORY_SEPARATOR . $iterator-&gt;getSubPathName());
                } else {
                  @copy($item, $dest . DIRECTORY_SEPARATOR . $iterator-&gt;getSubPathName());
                }
              }
          }
  </code></pre>
  
  <p>How can I fix/improve my function?</p>