marcorieser/laravel-sync

A git-like artisan command to easily sync files and folders between environments

Maintainers

Package info

github.com/marcorieser/laravel-sync

pkg:composer/marcorieser/laravel-sync

Transparency log

Fund package maintenance!

marcorieser

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 2

v0.1.0 2026-07-24 07:39 UTC

This package is auto-updated.

Last update: 2026-07-24 12:18:49 UTC


README

Laravel Sync

Packagist PHP from Packagist Laravel versions GitHub Workflow Status (main) Total Downloads

A git-like artisan command to easily sync files and folders between environments via rsync.

Requirements

  • rsync on both your local machine and the remote host
  • A working ssh setup between your local machine and the remote host (agent or ~/.ssh/config)

Installation

You can install the package via Composer:

composer require marcorieser/laravel-sync

Publish the config file:

php artisan vendor:publish --tag="laravel-sync-config"

This publishes config/sync.php:

return [

    'remotes' => [

        // 'production' => [
        //     'user' => 'forge',
        //     'host' => '104.26.3.113',
        //     'port' => 22,
        //     'root' => '/home/forge/example.com',
        //     'read_only' => env('SYNC_PRODUCTION_READ_ONLY', true),
        // ],

    ],

    'recipes' => [

        // 'assets' => ['storage/app/assets/', 'storage/app/img/'],

    ],

    'options' => [
        '--archive',
    ],

];

Remotes

Each remote needs a root path. Add user and host to sync with an actual server over ssh; omit both to treat the remote as a plain local path (handy for syncing between two projects on the same machine, no ssh involved).

Key Description
user The username to log in to the host. Omit together with host for a local remote.
host The IP address or hostname of the server. Omit together with user for a local remote.
port The SSH port to use. Defaults to 22.
root The absolute path to the project's root folder.
read_only When true, blocks push to this remote. Defaults to false.

Recipes

Recipes name a set of paths, relative to your project's root, that belong together:

'recipes' => [
    'assets' => ['storage/app/assets/', 'storage/app/img/'],
    'env' => ['.env'],
],

Options

The default rsync options, used whenever --option isn't passed on the command line:

'options' => [
    '--archive',
],

Usage

php artisan sync {push|pull} {remote} {recipe...} [options]
Command Description
sync Run the sync.
sync:list Preview the origin, target, options, and port in a table, without syncing.
sync:commands Print the rsync commands that would be run, without syncing.
Option Description
-O, --option=* Override the default rsync options. Repeatable.
-D, --dry Perform a dry run, with real-time output.
-A, --all Sync every configured recipe.
-v Show real-time output while syncing (progress, stats, ...).

Any argument you omit is prompted for interactively (operation, remote, recipes, and rsync options), unless you pass --no-interaction, in which case a missing required value fails fast with a clear error instead of prompting — and any real (non-dry) sync runs immediately without a confirmation prompt.

Use --dry for a dry run, not --option=--dry-run — only --dry skips the confirmation prompt, forces real-time output, and reports it as a dry run instead of a completed sync.

Examples

# Pull the "assets" recipe from "staging"
php artisan sync pull staging assets

# Push "assets" to "production" with custom rsync options
php artisan sync push production assets --option=-avh --option=--delete

# Preview a pull as a dry run, with real-time output
php artisan sync pull staging assets --dry

# Sync every recipe
php artisan sync push production --all

# Preview what would run, without syncing
php artisan sync:list pull staging assets
php artisan sync:commands pull staging assets

# Fully interactive
php artisan sync

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Thank you for considering contributing to Laravel Sync! Please review our contributing guide to get started.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

Laravel Sync is open-sourced software licensed under the MIT license.