helpers\BaseFileHelper copyDirectory()

copyDirectory() public static method

Copies a whole directory as another one.

The files and sub-directories will also be copied over.

public static void copyDirectory ( $src, $dst, $options = [] )
$src string

The source directory

$dst string

The destination directory

$options array

Options for directory copy. Valid options are:

  • dirMode: integer, the permission to be set for newly copied directories. Defaults to 0775.
  • fileMode: integer, the permission to be set for newly copied files. Defaults to the current environment setting.
  • filter: callback, a PHP callback that is called for each directory or file. The signature of the callback should be: function ($path), where $path refers the full path to be filtered. The callback can return one of the following values:

    • true: the directory or file will be copied (the "only" and "except" options will be ignored)
    • false: the directory or file will NOT be copied (the "only" and "except" options will be ignored)
    • null: the "only" and "except" options will determine whether the directory or file should be copied
  • only: array, list of patterns that the file paths should match if they want to be copied. A path matches a pattern if it contains the pattern string at its end. For example, '.php' matches all file paths ending with '.php'. Note, the '/' characters in a pattern matches both '/' and '\' in the paths. If a file path matches a pattern in both "only" and "except", it will NOT be copied.
  • except: array, list of patterns that the files or directories should match if they want to be excluded from being copied. A path matches a pattern if it contains the pattern string at its end. Patterns ending with '/' apply to directory paths only, and patterns not ending with '/' apply to file paths only. For example, '/a/b' matches all file paths ending with '/a/b'; and '.svn/' matches directory paths ending with '.svn'. Note, the '/' characters in a pattern matches both '/' and '\' in the paths.
  • caseSensitive: boolean, whether patterns specified at "only" or "except" should be case sensitive. Defaults to true.
  • recursive: boolean, whether the files under the subdirectories should also be copied. Defaults to true.
  • beforeCopy: callback, a PHP callback that is called before copying each sub-directory or file. If the callback returns false, the copy operation for the sub-directory or file will be cancelled. The signature of the callback should be: function ($from, $to), where $from is the sub-directory or file to be copied from, while $to is the copy target.
  • afterCopy: callback, a PHP callback that is called after each sub-directory or file is successfully copied. The signature of the callback should be: function ($from, $to), where $from is the sub-directory or file copied from, while $to is the copy target.
throws yii\base\InvalidParamException

if unable to open directory

doc_Yii
2016-10-30 17:04:43
Comments
Leave a Comment

Please login to continue.