PHPackages                             woda/laravel-worktrees - 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. [Database &amp; ORM](/categories/database)
4. /
5. woda/laravel-worktrees

ActiveLibrary[Database &amp; ORM](/categories/database)

woda/laravel-worktrees
======================

Git worktree management with database cloning for Laravel

v0.1.4(2mo ago)2204—0%MITPHPPHP ^8.2CI failing

Since Feb 20Pushed 2mo agoCompare

[ Source](https://github.com/wwwoda/laravel-worktrees)[ Packagist](https://packagist.org/packages/woda/laravel-worktrees)[ Docs](https://github.com/wwwoda/laravel-worktrees)[ RSS](/packages/woda-laravel-worktrees/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (12)Versions (8)Used By (0)

Laravel Worktrees
=================

[](#laravel-worktrees)

Git worktree management with database cloning for Laravel.

Create isolated development environments from your Laravel project using git worktrees. Each worktree gets its own branch, dependencies, database clone, and frontend build.

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

[](#installation)

```
composer require woda/laravel-worktrees
```

Publish the config (optional):

```
php artisan vendor:publish --tag=worktrees-config
```

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

[](#configuration)

```
// config/worktrees.php
return [
    'base_path' => env('WORKTREE_BASE_PATH', dirname(base_path())),
    'branch_prefix' => env('WORKTREE_BRANCH_PREFIX', ''),
    'base_branch' => env('WORKTREE_BASE_BRANCH', 'master'),
    'copy_files' => ['.env'],

    'database' => [
        'strategy' => env('WORKTREE_DB_STRATEGY', 'auto'), // auto|sqlite|mysql|pgsql|none
        'sqlite_copy' => true,
        'mysql_docker_container' => env('WORKTREE_DB_MYSQL_DOCKER_CONTAINER'),
        'pgsql_docker_container' => env('WORKTREE_DB_PGSQL_DOCKER_CONTAINER'),
        'docker_host' => env('WORKTREE_DB_DOCKER_HOST', '127.0.0.1'),
    ],

    'ports' => [
        'app_base' => (int) env('WORKTREE_APP_PORT_BASE', 8100),
        'vite_base' => (int) env('WORKTREE_VITE_PORT_BASE', 5200),
    ],

    'bootstrap' => [
        'node_package_manager' => env('WORKTREE_NODE_PM', 'pnpm'),
        'build_frontend' => true,
        'run_migrations' => true,
    ],

    'ide' => [
        'command' => env('WORKTREE_IDE_COMMAND', 'phpstorm'),
    ],
];
```

Commands
--------

[](#commands)

### `worktree:create`

[](#worktreecreate)

Create a worktree with full environment isolation.

```
php artisan worktree:create my-feature
php artisan worktree:create --issue=42        # From GitHub issue
php artisan worktree:create --pr=10           # From pull request
php artisan worktree:create --branch=existing # From existing branch
php artisan worktree:create                   # Interactive mode
```

Options: `--branch`, `--base`, `--issue`, `--pr`, `--skip-deps`, `--skip-build`, `--skip-db`

### `worktree:list`

[](#worktreelist)

```
php artisan worktree:list
php artisan worktree:list --json
```

### `worktree:delete`

[](#worktreedelete)

```
php artisan worktree:delete my-feature
php artisan worktree:delete my-feature --force     # Skip safety checks
php artisan worktree:delete my-feature --keep-db    # Keep cloned database
```

### `worktree:cleanup`

[](#worktreecleanup)

Remove stale worktrees.

```
php artisan worktree:cleanup --dry-run
php artisan worktree:cleanup --force
```

### `worktree:open`

[](#worktreeopen)

Open a worktree in your IDE.

```
php artisan worktree:open my-feature
```

Database Strategies
-------------------

[](#database-strategies)

The `database.strategy` config determines how databases are cloned:

StrategyBehavior`auto`Detect from `database.default` config`sqlite`Copy the SQLite file into the worktree`mysql``mysqldump | mysql` into a new database`pgsql``pg_dump | psql` into a new database`none`Skip database cloningDocker containers are supported for MySQL and PostgreSQL — set the container name in config and the commands will be wrapped with `docker exec`.

Port Isolation (Sail)
---------------------

[](#port-isolation-sail)

When running multiple worktrees with Laravel Sail, each worktree needs unique host ports to avoid conflicts. If your `.env` contains `APP_PORT` or `VITE_PORT`, the package will automatically derive unique ports per worktree.

Ports are computed as `base + (crc32(name) % 900)`, giving ranges of 8100–8999 for `APP_PORT` and 5200–6099 for `VITE_PORT` by default. Configure the base ports in `config/worktrees.php` or via environment variables:

```
WORKTREE_APP_PORT_BASE=8100
WORKTREE_VITE_PORT_BASE=5200
```

Port replacement only applies when the key already exists in your `.env` file — it won't inject ports you haven't defined.

ProcessManager Contract
-----------------------

[](#processmanager-contract)

The package binds a `NullProcessManager` by default. To integrate with a process manager (e.g. screen sessions, tmux), implement `Woda\Worktrees\Contracts\ProcessManager`:

```
interface ProcessManager
{
    public function isRunning(string $worktreeName): bool;
    public function terminate(string $worktreeName): void;
    public function runningLabel(string $worktreeName): string|null;
}
```

Bind your implementation in a service provider:

```
$this->app->bind(ProcessManager::class, MyProcessManager::class);
```

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11 or 12

License
-------

[](#license)

MIT

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance84

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.7% 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

5

Last Release

84d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1c3a6b11aea9668c9e9ca0c0f8515ef114d344acb552c695d715d35d5b388ea4?d=identicon)[woda](/maintainers/woda)

---

Top Contributors

[![developeratexample](https://avatars.githubusercontent.com/u/14004359?v=4)](https://github.com/developeratexample "developeratexample (11 commits)")[![davidmondok](https://avatars.githubusercontent.com/u/3883758?v=4)](https://github.com/davidmondok "davidmondok (1 commits)")

---

Tags

laraveldatabasegitcloningworktree

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/woda-laravel-worktrees/health.svg)

```
[![Health](https://phpackages.com/badges/woda-laravel-worktrees/health.svg)](https://phpackages.com/packages/woda-laravel-worktrees)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[cybercog/laravel-clickhouse

ClickHouse migrations for Laravel

163166.8k](/packages/cybercog-laravel-clickhouse)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)[orptech/laravel-migration-partition

Laravel extensions that extends Illuminate to enable partitioned table creation within Laravel migrations.

3426.7k](/packages/orptech-laravel-migration-partition)[webparking/laravel-type-safe-collection

This package provides type-safe extension of the laravel collection, forcing a single type of object.

378.2k](/packages/webparking-laravel-type-safe-collection)

PHPackages © 2026

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