PHPackages                             drlopes/template-sync - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. drlopes/template-sync

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

drlopes/template-sync
=====================

This is my package template-sync

v1.1(3w ago)04MITPHPPHP ^8.4CI passing

Since May 16Pushed 3w agoCompare

[ Source](https://github.com/drlopes/template_sync)[ Packagist](https://packagist.org/packages/drlopes/template-sync)[ Docs](https://github.com/drlopes/template-sync)[ GitHub Sponsors]()[ RSS](/packages/drlopes-template-sync/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (12)Versions (3)Used By (0)

Template Sync
=============

[](#template-sync)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9fed6c9a64bcd570f02a55d2e1cd7a06f57ae4db0fa2e471d2f641cdf8466389/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64726c6f7065732f74656d706c6174652d73796e632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/drlopes/template-sync)[![GitHub Tests Action Status](https://camo.githubusercontent.com/25f823bb619f0ed6939f23f050df85c93b2284ef23774afe6e3402234e0784bc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f64726c6f7065732f74656d706c6174652d73796e632f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/drlopes/template-sync/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/e689ef94c07e374d4a0d2eb748d1aede3b97d41f925c8b121a5f2700912b6d37/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f64726c6f7065732f74656d706c6174652d73796e632f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/drlopes/template-sync/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/cfc498213af0df9bc0878b38c5c20c14820d26ec9eef0bd8569c4311dfc50b64/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64726c6f7065732f74656d706c6174652d73796e632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/drlopes/template-sync)

A Laravel package that keeps your project in sync with the template repository it was created from. Run one command to pull in the latest changes from your template — conflicts are caught, local overrides are preserved, and a backup branch is created before every sync.

Installation
------------

[](#installation)

```
composer require drlopes/template-sync
```

Publish the config file:

```
php artisan vendor:publish --tag="template-sync-config"
```

Usage
-----

[](#usage)

### 1. Connect to your template

[](#1-connect-to-your-template)

Run the interactive setup command once. It prompts for your template repository URL and preferences, writes `config/template-sync.php`, and adds the git remote:

```
php artisan template:connect
```

You will be asked for:

- **Template repository URL** — the GitHub/GitLab URL of the template repo
- **Remote name** — the git remote name to use (default: `template`)
- **Branch** — which branch on the template to merge from (default: `main`)
- **Allow unrelated histories** — pass `--allow-unrelated-histories` to git merge; needed when the repo was created from a GitHub template
- **Auto-delete backup branch** — whether to remove the backup branch after a successful sync
- **Excluded paths** — files to keep at your local version even when the template changes them

### 2. Sync template changes

[](#2-sync-template-changes)

Pull in the latest changes from the template at any time:

```
php artisan template:update
```

The command will:

1. Add the template remote if it is missing
2. Create a backup branch (e.g. `backup/before-template-update-2025-05-16`) so you have a restore point
3. Fetch and merge the template branch
4. If the merge conflicts, **pause** with the merge in progress so you can resolve the conflicts yourself (see below)
5. If the merge succeeds, restore any excluded paths to their local versions, then commit

### Resolving conflicts

[](#resolving-conflicts)

When the merge runs into conflicts, the command stops and leaves the repository in a mid-merge state — your working tree contains the conflict markers, just like a normal `git merge`. You then have two options:

**Finish the sync** — fix the conflicts in your editor, stage the resolved files, and continue:

```
# edit the conflicted files...
git add
php artisan template:update --continue
```

`--continue` re-applies your excluded paths, creates the sync commit, and cleans up the backup branch if `delete_on_success` is enabled.

**Abort the sync** — discard the merge and return to where you were:

```
php artisan template:update --abort
```

`--abort` runs `git merge --abort` and leaves the backup branch in place so you can still inspect it.

While a sync is paused, re-running `php artisan template:update` without a flag will refuse to start a new sync and remind you to use `--continue` or `--abort`.

Configuration
-------------

[](#configuration)

```
// config/template-sync.php

return [

    /*
     * The name of the git remote pointing to the template repository.
     */
    'remote_name' => 'template',

    /*
     * The URL of the template repository.
     * Set this manually or run: php artisan template:connect
     */
    'url' => null,

    /*
     * The branch on the template repository to merge from.
     */
    'branch' => 'main',

    /*
     * Merge strategy. Currently only 'merge' is supported.
     */
    'merge_strategy' => 'merge',

    /*
     * Whether to pass --allow-unrelated-histories to git merge.
     * Enable this if git refuses to merge due to unrelated histories
     * (common when the repo was created from a GitHub template).
     */
    'allow_unrelated_histories' => false,

    /*
     * Backup branch settings. A backup branch is created before every
     * sync so you have a restore point if anything goes wrong.
     */
    'backup_branch' => [
        'enabled' => true,
        'prefix' => 'backup/before-template-update',
        'delete_on_success' => true,
    ],

    /*
     * Paths to keep at their local version even when the template changes them.
     * After merging, these files are restored to HEAD before committing.
     */
    'excluded_paths' => [
        // 'README.md',
        // '.env.example',
    ],

];
```

### Excluded paths

[](#excluded-paths)

Use `excluded_paths` for files your project has customised and should never receive template updates. After every successful merge, those files are restored to your local version before the commit is made, so template changes to them are silently dropped.

### Backup branch

[](#backup-branch)

Before every sync, a branch named `{prefix}-{date}` (e.g. `backup/before-template-update-2025-05-16`) is created at your current HEAD as a safety net. It is preserved whenever the sync pauses on conflicts or is aborted, so you can always `git checkout` it to get back to your previous state. Set `delete_on_success` to `false` to keep it even after a clean sync.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Daniel Lopes](https://github.com/drlopes)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance95

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

24d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f4b223efdbb8317ed26f2aa1b361f4df8924ee8dd2507a810dc895f418cefaf9?d=identicon)[DanielRLOo](/maintainers/DanielRLOo)

---

Top Contributors

[![drlopes](https://avatars.githubusercontent.com/u/84995988?v=4)](https://github.com/drlopes "drlopes (4 commits)")

---

Tags

laravelDaniel Lopestemplate-sync

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/drlopes-template-sync/health.svg)

```
[![Health](https://phpackages.com/badges/drlopes-template-sync/health.svg)](https://phpackages.com/packages/drlopes-template-sync)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.8k33.0M871](/packages/spatie-laravel-data)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.3M41](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

327482.0k25](/packages/codewithdennis-filament-select-tree)[nativephp/desktop

NativePHP for Desktop

37833.6k8](/packages/nativephp-desktop)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124581.3k](/packages/worksome-exchange)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3913.7k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
