helgesverre / vapor-swap
Manage Laravel Vapor profiles and switch accounts per terminal or permanently.
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.9
- symfony/console: ^7.4
Requires (Dev)
- laravel/pint: ^1.24
- phpunit/phpunit: ^11.5
- symfony/process: ^7.4
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Vapor Swap
Save your Laravel Vapor accounts and switch between them. Each saved profile contains an API token and a team.
Requires PHP 8.2+, Composer, and the Vapor CLI. Terminal switching works with Zsh, Bash, and Fish on macOS/Linux.
Install
composer global require helgesverre/vapor-swap
If vapor-swap is not found, add the directory printed by composer global config bin-dir --absolute to your PATH.
Shell setup
Add this to ~/.zshrc:
eval "$(vapor-swap init zsh)"
Then run source ~/.zshrc or open a new terminal.
For Bash, add eval "$(vapor-swap init bash)" to ~/.bashrc. For Fish, add vapor-swap init fish | source to ~/.config/fish/config.fish.
Usage
vapor-swap add work # Prompts for a token and team vapor-swap add personal --token APITOKENHERE --team 50346 vapor-swap list # Show saved profiles vapor-swap swap work # Switch this terminal vapor deploy production # Use Vapor as usual vapor-swap swap personal --sticky # Set the default for future terminals vapor-swap current # Show the current account and team vapor-swap reset # Return to the saved default vapor-swap remove work # Remove a profile
swap leaves other terminals alone. --sticky updates ~/.laravel-vapor/config.json and clears this terminal's temporary selection. Existing terminals with their own selection keep it.
Use vapor after switching; calling vendor/bin/vapor directly bypasses the terminal selection.
A token with one team selects it automatically. With multiple teams, you choose from a list. Adding a profile does not switch to it. Use add work --replace to update an existing profile.
For scripts, use --token-stdin and --team. list and current support --json. Run vapor-swap <command> --help for all options.
Zsh completions
mkdir -p ~/.zsh/completions vapor-swap completion zsh > ~/.zsh/completions/_vapor-swap
Add these lines to ~/.zshrc, before any existing compinit call:
fpath=("$HOME/.zsh/completions" $fpath) autoload -Uz compinit && compinit
If your Zsh setup already calls compinit, keep that call and only add the fpath line before it. Open a new terminal to enable completions.
Stored credentials
Profiles are saved in ~/.vapor-swap/config.json. Tokens are stored as plaintext with private file permissions, like Vapor's own config. Temporary selections are saved in ~/.vapor-swap/sessions/; old files can be deleted once the shells using them have closed.
Removing a profile does not revoke its token or clear existing authentication.
Development
composer install
composer test
composer lint
Tests use disposable home directories and fake credentials. CI tests PHP 8.2–8.5, macOS, Windows, and the real Vapor CLI. PHP 8.1 and 8.6 run as compatibility probes.
