Download the PHP package diegobvasco/php-rsync without Composer

On this page you can find all versions of the php package diegobvasco/php-rsync. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-rsync

PHP Rsync

GitHub Workflow Status (master) Total Downloads Latest Version License


A pure-PHP directory synchronization tool inspired by the rsync command. Sync directories by copying new and modified files, removing deleted files, and skipping exclusions — all with a clean fluent API.

Requires PHP 8.5+

Installation

Usage

Basic Sync

With Exclusions

With Delete Mode

With Real-Time Output

Dry Run

Accessing Results

Skip Pattern Syntax

Pattern Meaning
*.log All .log files
vendor/* Everything inside vendor/
**/*.log Any .log file in any subdirectory
logs/ The logs/ directory and all its contents
??.txt Two-character .txt filenames
[abc].txt Files named a.txt, b.txt, or c.txt
[^ab].log Any single-character .log filename except a or b

How It Works

  1. Scans the source directory for all files
  2. Filters out files matching exclusion patterns
  3. Compares each file's modification time and size against the destination
  4. Copies only new or changed files
  5. Deletes destination files that no longer exist in the source (when delete() is enabled)
  6. Removes empty directories from the destination
  7. Returns a Result object with full sync details

API

Rsync

The optional Output interface receives callbacks for each file action during sync. A TerminalOutput implementation is included that prints to STDOUT (or a custom stream).

The optional Filesystem argument lets you swap the default LocalFilesystem (which uses PHP's global FS functions) for any other implementation — useful for testing against InMemoryFilesystem or a custom backend. It is backward compatible: new Rsync() and new Rsync($output) keep working unchanged.

Performance: file checksums are computed lazily — the expensive xxh128 hash only runs in --checksum mode (or when you read $file->checksum). The destination tree is scanned only when a delete mode is enabled; otherwise each source file is checked against its destination counterpart individually.

Core

Method Description
copy(string $source, string $destination): self Set source and destination directories
skip(string\|array $patterns): self Add glob patterns to exclude from sync
delete(): self Enable delete mode — removes destination files not in source
recursive(): self Enable recursive mode
archive(): self Enable archive mode (equivalent to -rlptgoD)
run(): Result Execute the sync and return results
toCommand(): string Generate equivalent rsync shell command for debugging
reset(): self Reset all flags and options

Metadata Preservation

Method Description
times(): self Preserve modification times (--times)
perms(): self Preserve permissions (--perms)
owner(): self Preserve owner (--owner)
group(): self Preserve group (--group)
acls(): self Preserve ACLs (--acls)
xattrs(): self Preserve extended attributes (--xattrs)
devices(): self Preserve device files (--devices)
specials(): self Preserve special files (--specials)
numericIds(): self Don't map uid/gid values (--numeric-ids)

Comparison

Method Description
checksum(): self Use checksum instead of mod-time & size (--checksum)
ignoreTimes(): self Don't skip files that match size and time (--ignore-times)
sizeOnly(): self Skip files that match size only (--size-only)
update(): self Skip files newer on the receiver (--update)

Excludes / Includes

Method Description
exclude(string\|array $patterns): self Add patterns to exclude (--exclude)
excludeFrom(string $file): self Read exclude patterns from file (--exclude-from)
excludeDir(string\|array $patterns): self Add directory exclusion patterns (--exclude-dir)
include(string\|array $patterns): self Add patterns to include (--include)
includeFrom(string $file): self Read include patterns from file (--include-from)
pruneEmptyDirs(): self Remove empty directories from file list (--prune-empty-dirs)

Backup

Method Description
backup(): self Make backups of changed files (--backup)
backupDir(string $dir): self Set backup directory (--backup-dir)
suffix(string $suffix): self Set backup suffix (--suffix)

Symlinks / Hardlinks

Method Description
links(): self Copy symlinks as symlinks (--links)
copyLinks(): self Transform symlinks to referent files (--copy-links)
copyUnsafeLinks(): self Transform unsafe symlinks to referent files in directories (--copy-unsafe-links)
safeLinks(): self Ignore symlinks that go outside tree (--safe-links)
hardLinks(): self Preserve hard links (--hard-links)

Size Limits

Method Description
maxSize(int\|string $size): self Maximum file size to transfer (--max-size)
minSize(int\|string $size): self Minimum file size to transfer (--min-size)

Behavior

Method Description
dryRun(): self Show what would be done without doing it (--dry-run)
force(): self Force deletion of non-empty directories (--force)
removeSourceFiles(): self Remove source files after successful transfer (--remove-source-files)

Output

Method Description
verbose(): self Verbose output (--verbose)
quiet(): self Suppress output (--quiet)
progress(): self Show progress (--progress)
stats(): self Show statistics (--stats)
itemizeChanges(): self Show itemized changes (--itemize-changes)
humanReadable(): self Human-readable numbers (--human-readable)

Delete Modes

Method Description
delete(): self Delete files in destination not in source (--delete)
deleteBefore(): self Delete before transfer (--delete-before)
deleteAfter(): self Delete after transfer (--delete-after)
deleteExcluded(): self Delete excluded files from destination (--delete-excluded)

Result

Method Description
copiedCount(): int Number of files copied
deletedCount(): int Number of files deleted
skippedCount(): int Number of files skipped
totalBytesCopied(): int Total bytes copied
totalBytesDeleted(): int Total bytes deleted
summary(): string Human-readable summary
copiedPaths(): array List of copied file paths
deletedPaths(): array List of deleted file paths
skippedPaths(): array List of skipped file paths

FileInfo

Method Description
formattedSize(): string Human-readable file size (e.g. "12.5 KB")
formattedMtime(): string ISO 8601 formatted modification time

Output (interface)

Implement this to receive real-time file action callbacks during sync.

Method Description
copied(FileInfo $file): void Called when a file is copied
deleted(FileInfo $file): void Called when a file is deleted
skipped(FileInfo $file): void Called when a file is skipped

TerminalOutput

Built-in implementation of Output that prints actions to a stream.

Defaults to STDOUT. Pass a custom stream to redirect output:

Filesystem (interface)

Abstraction over all filesystem operations. The default LocalFilesystem wraps PHP's global FS functions; InMemoryFilesystem is a disk-less implementation that is handy for tests:

Quality

This package enforces high code quality standards:

Changelog

Please see CHANGELOG for more information on recent changes.

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see LICENSE for more information.


All versions of php-rsync with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5.0
ext-hash Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package diegobvasco/php-rsync contains the following files

Loading the files please wait ...