Download the PHP package anthonyiles/worktree-isolation without Composer

On this page you can find all versions of the php package anthonyiles/worktree-isolation. 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 worktree-isolation

Worktree Isolation

Per-worktree test database isolation and bootstrap automation for PHP projects.

Works with any PHP project and any development environment: native PHP (Herd, Valet), Docker Compose, Laravel Sail, or any standalone Docker image. No framework required — Laravel integration is included but optional.

The Problem

When using git worktree with a PHP project, each worktree needs:

This package automates all of that. After installation, every git worktree add automatically bootstraps the new worktree — no manual steps required.

Requirements

Installation

Every scenario starts the same way:

This installs three commands under vendor/bin/ — worktree-install, worktree-setup, test, worktree-clean — kept in sync automatically by Composer. Nothing is copied into your project except the config file you choose to write (below). Laravel projects can swap vendor/bin/worktree-install for php artisan worktree:install in any scenario below — same flags, artisan just delegates to the same installer.

Then pick the section that matches your setup:


Native PHP

For Herd, Valet, or any setup where composer, npm, and your test runner already run directly on the host.

This is the default runtime, so no --runtime flag is needed. It writes .worktree-isolation.env:

Non-Laravel projects should also set WORKTREE_TEST_COMMAND — see Custom Test Command.


Docker Compose

For projects where the app runs as a service in docker-compose.yml, started with docker compose up -d.

--compose-service should match the service name in your docker-compose.yml that has PHP, Composer, and Node available (default: app). This writes:

composer install, npm install, and your test command all run via docker compose exec -T, so the compose stack must already be up when you run git worktree add or vendor/bin/test.


Laravel Sail

Sail is just Laravel's name for a pre-built Docker image, so it uses the docker-image runtime — this also covers any other standalone Docker image (non-Sail) the same way, just with different --docker-image/--docker-network values.

This writes:

composer install, npm install, and your test command each run via a throwaway docker run --rm against that image, attached to the given network — the image must already be built (vendor/bin/sail build, or docker compose build for a non-Sail standalone image).


Custom Test Command

By default, tests run via php artisan test. For non-Laravel projects (in any of the scenarios above), set a custom test command:

Or set WORKTREE_TEST_COMMAND directly in .worktree-isolation.env:

For Other Engineers

After pulling a branch that has .worktree-isolation.env committed, each engineer just runs:

The command is idempotent — it detects the existing .worktree-isolation.env and only (re)configures the git hook.

Hook activation is local to that clone (git config --local), so each engineer runs this once per clone — same as any git-hooks tool (Husky, pre-commit, etc.), since git never auto-trusts hooks from a fresh clone. It is not tied to any branch: because the hook command is registered as an absolute path resolved at install time, worktrees created from any branch — including ones that never had this package's config committed — get bootstrapped automatically. You don't need to merge anything hook-related into every branch you plan to git worktree add from.

How It Works

Automatic Worktree Bootstrap

When you run git worktree add, the post-checkout hook detects the new worktree and runs worktree-setup (straight out of vendor/), which:

  1. Copies .env from the main repo
  2. Copies .env.testing (or falls back to .env.testing.example)
  3. Forces TEST_DB_PER_WORKTREE=true in the worktree's .env.testing
  4. Runs composer install (via the configured runtime)
  5. Derives the per-worktree database name, creates it, and writes it as DB_DATABASE in the worktree's .env.testing
  6. Runs npm install (via the configured runtime)

Per-Worktree Test Databases

The database name is derived from the worktree directory:

For example, a worktree at ../worktrees/my-project/feature-auth gets database testing-feature-auth. A safety guard ensures the derived name always contains "test" to prevent accidental use of production databases.

Because this name is written directly into .env.testing at bootstrap time (step 5 above), it applies no matter how you run tests — vendor/bin/test, sail test, php artisan test, vendor/bin/phpunit, or anything else that reads .env.testing the normal way. vendor/bin/test also re-derives and re-creates the database dynamically on every run, so it stays correct even if step 5 failed at setup time (e.g. the database wasn't reachable yet) or the worktree directory gets renamed later.

Running Tests

From any worktree:

Cleaning Up

Drop all per-worktree test databases:

This lists all databases matching the {base}-* pattern and asks for confirmation before dropping them. Use --force to skip the prompt.

Configuration

Runtime Drivers

Driver When to use Requirements
native (default) Herd, Valet, any local PHP/Node PHP, Composer, Node on host
docker-compose Docker Compose projects Running docker compose up -d
docker-image Sail or standalone Docker image Pre-built Docker image

.worktree-isolation.env (full reference)

Project-level configuration (committed to repo). The scenario sections above show the subset of these that matter for each runtime — this is the complete list:

Laravel Config (optional)

Laravel projects can also publish a config file:

This creates config/worktree-isolation.php which mirrors the .worktree-isolation.env settings through Laravel's config system.

Available Commands

All installed via Composer's bin mechanism — vendor/bin/* always matches the installed package version, nothing to republish on upgrade.

Command Purpose
vendor/bin/test Run tests with per-worktree database isolation
vendor/bin/worktree-setup Bootstrap a worktree (env files, dependencies) — normally run automatically by the git hook
vendor/bin/worktree-install Install/configure worktree isolation (no framework needed)
vendor/bin/worktree-clean Drop per-worktree test databases (no framework needed)

AI Agent Integration

The per-worktree database is baked into .env.testing at bootstrap time (see Per-Worktree Test Databases), so an agent that runs sail test or php artisan test directly still hits the correct, isolated database — it doesn't depend on the agent knowing about vendor/bin/test. vendor/bin/test is still worth pointing agents at for its runtime dispatch (docker-compose/docker-image projects need composer/npm/test commands routed into the right container). Add this to your project's cursor rules or AGENTS.md:

License

MIT


All versions of worktree-isolation with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
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 anthonyiles/worktree-isolation contains the following files

Loading the files please wait ...