- How do I install Laravel Envoy in my Laravel project?
- Run `composer require laravel/envoy` in your project directory. Envoy will automatically create an `envoy.php` configuration file in your project root. No additional setup is required unless you need custom SSH configurations.
- What Laravel versions does Envoy support?
- Envoy is designed for Laravel 8.x and 9.x, with backward compatibility for Laravel 7.x. Check the [official documentation](https://laravel.com/docs/envoy) for version-specific details, as newer Laravel releases may require updates.
- Can I use Envoy for zero-downtime deployments?
- Envoy supports sequential or parallel task execution, making it suitable for basic zero-downtime workflows (e.g., stopping services, deploying code, restarting services). For advanced strategies like blue-green deployments, you may need to combine it with other tools or custom logic.
- How do I run Artisan commands remotely using Envoy?
- Define a task in `envoy.php` using the `@artisan` directive, e.g., `@artisan migrate`. Envoy will execute the command on the remote server via SSH. You can chain commands or run them conditionally using Blade syntax.
- Is Envoy secure for production deployments?
- Envoy itself is secure, but you must manage SSH keys and credentials carefully. Use Laravel Forge, AWS Secrets Manager, or encrypted `.env` files for sensitive data. Avoid hardcoding credentials in `envoy.php` or version-controlled files.
- How do I handle task failures in Envoy?
- Envoy doesn’t include built-in retry logic, but you can implement error handling in your Blade tasks using `@if` conditions or PHP try-catch blocks. For critical tasks, consider adding manual retries or integrating with monitoring tools like Laravel Horizon.
- Can I use Envoy with GitHub Actions or GitLab CI?
- Yes, Envoy works seamlessly with CI/CD pipelines. Add SSH keys to your CI environment and trigger Envoy tasks via a shell command, e.g., `php artisan envoy run deploy`. Ensure your CI has SSH access to the target servers.
- What’s the difference between Envoy and Laravel Forge/Vapor?
- Envoy is a lightweight, self-hosted tool for SSH-based automation, ideal for custom workflows. Forge and Vapor are managed Laravel hosting solutions that handle deployments, servers, and scaling automatically. Use Envoy for control over your infrastructure.
- How do I organize complex multi-server workflows in Envoy?
- Use Envoy’s `@servers` array to define groups of servers and `@task` blocks to chain operations. For parallel execution, separate tasks with `@parallel`. Example: Define `staging` and `production` servers, then run `@parallel` for simultaneous deployments.
- Does Envoy support Windows-based deployments?
- Envoy relies on SSH, which isn’t natively supported on Windows. Use Windows Subsystem for Linux (WSL) or a Linux-based CI/CD environment to run Envoy tasks. For pure Windows deployments, consider alternatives like PowerShell scripts or tools like Capistrano.