- How do I migrate from Laravel Envoy to Scotty in my Laravel project?
- Scotty is a drop-in replacement for Envoy. Replace `envoy:run` commands with `scotty run [macro]` in your `artisan` commands or CI scripts. Convert your Envoy tasks to Scotty’s annotated Bash format in a `Scotty.sh` file, using `@servers` and `@macro` directives. For example, if you had `envoy:run deploy`, use `scotty run deploy` instead. The syntax is simpler and more intuitive for SSH workflows.
- Does Scotty work with Laravel Forge or Envoyer for deployments?
- Yes, Scotty integrates seamlessly with Laravel Forge and Envoyer. Use Scotty for custom tasks not covered by Forge’s UI or to extend Envoyer’s workflows. For example, automate post-deploy tasks like cache clearing or queue restarts with Scotty while using Forge/Envoyer for core deployment steps. Just ensure your SSH keys are properly configured in Forge or Envoyer’s settings.
- Can I use Scotty in GitHub Actions or GitLab CI for Laravel deployments?
- Absolutely. Scotty works perfectly in CI/CD pipelines. Add it to your workflow by downloading the PHAR in your CI script, then running tasks like `scotty run deploy --branch=${{ github.ref_name }}`. Use SSH keys stored as CI secrets to authenticate. For GitLab CI, reference the key in `SSH_PRIVATE_KEY` and ensure your `~/.ssh/config` is properly set up or use Scotty’s inline server definitions.
- What Laravel versions does Scotty support, and does it require PHP dependencies?
- Scotty is language-agnostic and works with any Laravel version (5.8+) or PHP project. It has no PHP dependencies—it’s a standalone PHAR file, so it won’t bloat your `vendor/` directory. This makes it ideal for legacy PHP systems or non-Laravel projects needing SSH automation. However, its Laravel compatibility comes from its Envoy-like syntax, not PHP requirements.
- How do I handle dynamic server lists or environment-specific configurations in Scotty?
- Scotty uses Bash annotations for servers, but for dynamic lists, use environment variables or Bash includes. For example, define servers in a `.env` file (e.g., `SERVER_1=deployer@server1.com`) and reference them in your `Scotty.sh` with `@servers remote=$SERVER_1`. Alternatively, use Bash’s `source` to load server lists from a file. This avoids hardcoding servers and allows environment-specific setups.
- What’s the best way to debug failed Scotty tasks in production?
- For debugging, use Scotty’s `--pretend` flag to dry-run tasks without executing them. Redirect output to a log file with `scotty run deploy > deploy.log` for later inspection. If tasks fail, manually SSH into the server to check logs or use `scotty --verbose` for detailed output. Integrate Scotty logs with Laravel’s logging system or tools like Sentry for centralized monitoring.
- Is Scotty suitable for managing multi-server deployments (e.g., load-balanced apps)?
- Yes, Scotty excels at multi-server workflows. Use the `@servers` directive to define multiple servers (e.g., `@servers remote=deployer@server1.com,deployer@server2.com`) and run tasks in parallel with `@parallel`. For complex setups, leverage SSH config files (`~/.ssh/config`) to manage jump hosts or key-based auth. Scotty’s output clearly shows which server each task runs on, making debugging easier.
- How do I secure SSH keys for Scotty in CI/CD or shared environments?
- Store SSH private keys as CI secrets (e.g., GitHub Secrets or GitLab CI variables) and reference them in your `~/.ssh/config` or pass them directly to Scotty via environment variables. Avoid hardcoding keys in scripts. For shared environments, use SSH agent forwarding or deploy keys with restricted permissions. Scotty supports all standard SSH authentication methods, including certificates and passphrases.
- Can Scotty replace Deployer or Capistrano for PHP deployments?
- Scotty is a lighter alternative for SSH-based deployments, especially if you’re already using Bash for scripting. It’s simpler than Deployer or Capistrano for basic workflows (e.g., git pulls, composer installs) but lacks some advanced features like rollback strategies or multi-stage deployments. For Laravel, Scotty’s Envoy compatibility makes it a natural fit if you want to avoid Ruby (Capistrano) or PHP dependencies (Deployer).
- How do I test Scotty tasks locally before deploying to production?
- Test Scotty tasks locally by defining a `localhost` server in your `~/.ssh/config` or directly in `Scotty.sh` (e.g., `@servers remote=localhost`). Use `--pretend` to simulate runs without executing commands. For Laravel, mock remote tasks by creating a local directory mirroring your production setup. Validate outputs with `scotty run deploy --verbose` and compare them to expected results. Automate testing in CI with a staging environment.