Auto-configure
.envfiles for Git worktree projects in PhpStorm.
Worktree Env Configurator is a JetBrains plugin that detects when a Laravel project is opened as a Git worktree and automatically configures the .env file by copying it from the main project and adjusting APP_URL to match the worktree folder name.
- Homepage: GitHub
- Marketplace: JetBrains Marketplace
- Issues: GitHub Issues
| Not Configured | Configured |
|---|---|
![]() |
![]() |
When using Git worktrees with Laravel projects, each worktree lives in a separate folder (e.g., myapp-feature-payment) and needs its own .env with APP_URL pointing to the correct local hostname. With Laravel Herd or Valet, this means http://myapp-feature-payment.test.
Today this is manual: copy .env, edit APP_URL. This plugin automates it.
- Auto-detection — Detects Git worktree projects on open via
.gitfile parsing - Smart APP_URL — Preserves scheme, compound TLDs, port, and path from the original URL
- Status bar widget — Color-coded icon showing worktree
.envstatus at a glance - Tool window panel — Full status and actions in the right sidebar
- Live updates — UI reacts to
.envfile changes in real time - Configurable pattern — Use
{folder}placeholder for custom URL patterns .env.testingsupport — Optionally copies and configures the testing env- Smart notifications — Balloon with "Configure" and "Ignore" actions on project open
- Lowercase URLs — All generated
APP_URLvalues are lowercased for consistent hostname resolution
- IDE: PhpStorm 2024.3+ (or any IntelliJ-based IDE with PHP plugin, builds 243–263.*)
- Plugins: Git4Idea (bundled), PHP (bundled in PhpStorm)
- Java: JDK 17+
- Open PhpStorm → Settings → Plugins → Marketplace
- Search for "Worktree Env Configurator"
- Click Install and restart the IDE
Or install directly from: Worktree Env Configurator on JetBrains Marketplace
- Download the latest release
.zipfrom Releases - Open PhpStorm → Settings → Plugins → ⚙️ → Install Plugin from Disk...
- Select the
.zipfile and restart the IDE
- Open a Git worktree project in PhpStorm
- The plugin detects the worktree and shows a notification
- Click Configure .env — the
.envis copied andAPP_URLis adjusted - Status bar turns green when configured
Access via View → Tool Windows → Worktree Env or click the worktree icon in the right sidebar.
| Section | Description |
|---|---|
| Status | Shows configured/unconfigured state with color-coded icon and current APP_URL |
| Worktree Info | Displays worktree folder name and main project name |
| Actions | Configure .env, Open .env in editor, Refresh status |
The status bar widget (bottom-right) shows:
- Green icon —
.envis configured with correctAPP_URL(hover for URL) - Orange icon — Worktree detected but
.envnot yet configured (click to open tool window)
Available under Tools → Configure Worktree .env (only visible in worktree projects).
The plugin intelligently replaces only the hostname while preserving everything else:
Main Project .env |
Worktree Folder | Generated APP_URL |
|---|---|---|
http://myapp.test |
myapp-feature |
http://myapp-feature.test |
https://myapp.herd.local |
myapp-feature |
https://myapp-feature.herd.local |
http://myapp.dev.br:8080/api |
myapp-feature |
http://myapp-feature.dev.br:8080/api |
Or use a custom pattern in settings: http://{folder}.test
Settings → Tools → Worktree Env Configurator
| Setting | Default | Description |
|---|---|---|
| Auto-configure on open | true |
Show notification when a worktree is detected |
Copy .env.testing |
true |
Also configure .env.testing if it exists in the main project |
| Open in editor | true |
Open .env in the editor after configuration |
| Pattern | (empty) | Custom URL pattern using {folder} placeholder. Empty = auto-detect from main .env |
When you click "Ignore this project" on the notification, the project is added to an ignore list. Reset via Settings → Tools → Worktree Env Configurator → Reset Ignored Projects.
- On project open, reads the
.gitfile (not directory) — this indicates a worktree - Parses the
gitdir:path and resolves the main project viacommondir - Checks if
.envexists in the worktree with the correctAPP_URL - If not configured, shows a balloon notification with actions
- On configure: copies
.envfrom main project, replaces only theAPP_URLline - File system listener watches for
.envchanges and updates UI in real time
# Clone the repository
git clone git@github.com:jeffersongoncalves/worktree-env-plugin.git
cd worktree-env-plugin
# Build the plugin
./gradlew buildPlugin
# Run PhpStorm sandbox with plugin loaded
./gradlew runIde
# Run tests
./gradlew test
# Verify plugin compatibility
./gradlew verifyPluginThe built plugin archive will be in build/distributions/.
Jefferson Gonçalves — GitHub


