FastSitePHP\FileSystem\Sync

File System Sync

This class provides the ability for syncing of all files and directories from one directory to another directory. This class compares files using a hash (defaults to 'sha256') and updates the files if different. Additionally new files, deleted files, new empty directories, and deleted directories are handled.

Código Fonte

GitHub

Métodos

function dirFrom($new_value = null)

Propriedade Getter / Setter

Get or set the directory to sync from (source directory).

Retorna: string | $this

function dirTo($new_value = null)

Propriedade Getter / Setter

Get or set the directory to sync to (destination directory).

Retorna: string | $this

function excludeNames(array $new_value = null)

Propriedade Getter / Setter

Get or set an array of files/dir names to exclude. If a file/dir matches any names in the list then it will be excluded from the result. This property does not handle files in nested directories. For nested files use [excludeRegExPaths()].

Retorna: array | $this

excludeRegExPaths(array $new_value = null)

Propriedade Getter / Setter

Get or set an array of files/dir regex path expressions to exclude. If part of the full path matches any regex in the list then it will be excluded from the result.

Example usage:
    $sync->excludeRegExPaths(['/node_modules/']);

Retorna: array | $this

function summaryTitle($new_value = null)

Propriedade Getter / Setter

Get or set the summary title used for report output when calling [printResults()]. Defaults to 'File System Sync Results'.

Retorna: string | $this

function dryRun($new_value = null)

Propriedade Getter / Setter

Get or set a dry run boolean value for testing. When set to [true] no changes will be made when calling [sync()]. Defaults to [false].

Retorna: bool | $this

function hashAlgo($new_value = null)

Propriedade Getter / Setter

Get or set the hashing algorithm for comparing files when syncing. Defaults to 'sha256'.

Retorna: string | $this

function sync()

Sync files and directories (folders) from [dirFrom(path)] to [dirTo(path)]. The sync is recursive so all files and directories are synced in all sub-directories.

To view the results of the sync call [printResults()] after calling this function.

Retorna: $this

function printResults()

Output the result of [sync()] as a text summary. This includes a list of all affected files and directories and summary counts. This function will typically be used for CLI output, however if used on a web server then <br> will be used for line breaks.

Retorna: string