{"id":16541401,"url":"https://github.com/aerni/laravel-sync","last_synced_at":"2025-04-09T06:10:52.986Z","repository":{"id":56941511,"uuid":"319717707","full_name":"aerni/laravel-sync","owner":"aerni","description":"A git-like artisan command to easily sync files and folders between environments.","archived":false,"fork":false,"pushed_at":"2025-03-03T17:03:51.000Z","size":128,"stargazers_count":66,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T00:14:12.329Z","etag":null,"topics":["artisan-command","laravel","laravel-package","laravel-sync","sync"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aerni.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-08T17:53:27.000Z","updated_at":"2025-03-03T17:02:15.000Z","dependencies_parsed_at":"2024-10-27T11:10:42.839Z","dependency_job_id":"ce8d2a7e-43e7-46a7-9fe2-999abf781609","html_url":"https://github.com/aerni/laravel-sync","commit_stats":{"total_commits":60,"total_committers":2,"mean_commits":30.0,"dds":"0.16666666666666663","last_synced_commit":"6fabd2e25c44f9853a77f0565af4e272a65156a0"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aerni%2Flaravel-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aerni%2Flaravel-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aerni%2Flaravel-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aerni%2Flaravel-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aerni","download_url":"https://codeload.github.com/aerni/laravel-sync/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987285,"owners_count":21028895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artisan-command","laravel","laravel-package","laravel-sync","sync"],"created_at":"2024-10-11T18:54:54.949Z","updated_at":"2025-04-09T06:10:52.968Z","avatar_url":"https://github.com/aerni.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Packagist version](https://flat.badgen.net/packagist/v/aerni/sync/latest) ![Packagist Total Downloads](https://flat.badgen.net/packagist/dt/aerni/sync) ![License](https://flat.badgen.net/github/license/aerni/laravel-sync)\n\n# Laravel Sync\nThis package provides a git-like artisan command to easily sync files and folders between environments. This is super useful for assets, documents, and any other files that are untracked in your git repository.\n\nLaravel Sync is a no-brainer and the perfect companion for your deploy script. The days are over when you had to manually keep track of files and folders between your environments. Do yourself a favor and give it a try!\n\n## Requirements\n- `rsync` on both your source and destination machine\n- A working `SSH` setup between your source and destination machine\n\n## Installation\nInstall the package using Composer.\n\n```bash\ncomposer require aerni/sync\n```\n\nPublish the config of the package.\n\n```bash\nphp artisan vendor:publish --provider=\"Aerni\\Sync\\SyncServiceProvider\"\n```\n\nThe following config will be published to `config/sync.php`.\n\n```php\n\u003c?php\n\nreturn [\n\n    /*\n    |--------------------------------------------------------------------------\n    | Remotes\n    |--------------------------------------------------------------------------\n    |\n    | Define on or more remotes you want to sync with.\n    | Each remote is an array with 'user', 'host', 'root', and optional 'port'.\n    |\n    */\n\n    'remotes' =\u003e [\n\n        // 'production' =\u003e [\n        //     'user' =\u003e 'forge',\n        //     'host' =\u003e '104.26.3.113',\n        //     'port' =\u003e 1431,\n        //     'root' =\u003e '/home/forge/statamic.com',\n        //     'read_only' =\u003e false,\n        // ],\n\n    ],\n\n    /*\n    |--------------------------------------------------------------------------\n    | Recipes\n    |--------------------------------------------------------------------------\n    |\n    | Define one or more recipes with the paths you want to sync.\n    | Each recipe is an array of paths relative to your project's root.\n    |\n    */\n\n    'recipes' =\u003e [\n\n        // 'assets' =\u003e ['storage/app/assets/', 'storage/app/img/'],\n\n    ],\n\n    /*\n    |--------------------------------------------------------------------------\n    | Options\n    |--------------------------------------------------------------------------\n    |\n    | An array of default rsync options.\n    | You can override these options when executing the command.\n    |\n    */\n\n    'options' =\u003e [\n        '--archive',\n    ],\n\n];\n```\n\n## Configuration\nTo use this package, you have to define at least one remote and recipe.\n\n### Remotes\nEach remote consists of a `user`, `host`, and `root`. Optionally, you may also define the SSH `port` and make a remote `read_only`.\n\n| Key         | Description                                    |\n| ----------- | ---------------------------------------------- |\n| `user`      | The username to log in to the host             |\n| `host`      | The IP address of your server.                 |\n| `port`      | The SSH port to use for this connection        |\n| `root`      | The absolute path to the project's root folder |\n| `read_only` | Set to `true` to make the remote read-only     |\n\n```php\n'remotes' =\u003e [\n\n    'production' =\u003e [\n        'user' =\u003e 'forge',\n        'host' =\u003e '104.26.3.113',\n        'port' =\u003e 1431,\n        'root' =\u003e '/home/forge/statamic.com',\n        'read_only' =\u003e env('SYNC_PRODUCTION', true),\n    ],\n\n],\n```\n\nThe `read_only` option comes in handy if you want to prevent pushing to a remote from a certain environment, e.g. pushing to `production` from your local environment.\n\n### Recipes\nAdd any number of recipes with the paths you want to sync. Each recipe is an array of paths relative to your project's root.\n\n```php\n'recipes' =\u003e [\n    'assets' =\u003e ['storage/app/assets/', 'storage/app/img/'],\n    'env' =\u003e ['.env'],\n],\n```\n\n### Options\nConfigure the default rsync options to use when performing a sync. You can override these options when executing the command.\n\n```php\n'options' =\u003e [\n    '--archive',\n],\n```\n\n## The Command\nIf you know git, you'll feel right at home with the syntax of this command:\n\n```bash\nphp artisan [command] [operation] [remote] [recipe] [options]\n```\n\n### Command Structure\nThe structure of the command looks like this:\n\n| Structure   | Description                                      |\n| ----------- | ------------------------------------------------ |\n| `command`   | The command you want to use                      |\n| `operation` | The operation you want to use (`pull` or `push`) |\n| `remote`    | The remote you want to sync with                 |\n| `recipe`    | The recipe defining the paths to sync            |\n| `options`   | The options you want to use                      |\n\n### Available Commands\nYou have three commands at your disposal:\n\n| Command         | Description                                                |\n| --------------- | ---------------------------------------------------------- |\n| `sync`          | Perform the sync                                           |\n| `sync:list`     | List the origin, target, options, and port in a nice table |\n| `sync:commands` | List all rsync commands                                    |\n\n### Available Options\nYou may use the following options:\n\n| Option                | Description                                               |\n| --------------------- | --------------------------------------------------------- |\n| `-O*` or `--option=*` | Override the default rsync options                        |\n| `-D` or `--dry`       | Perform a dry run of the sync with real-time output       |\n| `-v` or `--verbose`   | Displays the real-time output of the sync in the terminal |\n\n## Usage Examples\n\nPull the assets recipe from the staging remote:\n```bash\nphp artisan sync pull staging assets\n```\n\nPush the assets recipe to the production remote with some custom rsync options:\n```bash\nphp artisan sync push production assets --option=-avh --option=--delete\n```\n\nPerform a dry run:\n```bash\nphp artisan sync pull staging assets --dry\n```\n\nEcho the real-time output of the sync in your terminal:\n```bash\nphp artisan sync pull staging assets --verbose\n```\n\nList the origin, target, options, and port in a nice table:\n```bash\nphp artisan sync:list pull staging assets\n```\n\nList all rsync commands:\n```bash\nphp artisan sync:commands pull staging assets\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faerni%2Flaravel-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faerni%2Flaravel-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faerni%2Flaravel-sync/lists"}