Laravel Envoy Script Generator

Generate a copy-ready Envoy.blade.php with servers, setup variables, and deployment tasks.

Laravel Envoy Script Generator

Generate a copy-ready Envoy.blade.php deployment script.

Used only in a comment header.
Format: name=user@host (you can also use name: user@host). Lines starting with # are ignored.
Must match a server name from the list above.
The script uses /releases and /current under this path.
Runs artisan down before and artisan up after deploy.
Adds artisan migrate --force to the deploy story.
Runs npm ci and npm run build on the server.
Runs artisan queue:restart after switching the symlink.
Paste extra Envoy tasks, hooks, or comments. This text is appended at the end of the generated file.
Processing…
No output yet
Configure settings and click Generate.
Copied

About Laravel Envoy Script Generator

Laravel Envoy Script Generator for Deployment Automation

Generate a clean, ready-to-run Envoy.blade.php file for Laravel Envoy without hand-writing repetitive deployment boilerplate. Paste your server list, repository URL, and deployment path, pick a few common options, then copy the script into your project and start running deployments with consistent, readable tasks.

Envoy shines when you want “just enough” automation: SSH into one or more servers, run a set of commands, and keep everything in version control. A well-structured Envoy file becomes the shared language between developers and operations, and it helps you avoid copy-pasting ad-hoc terminal commands during releases.

How the Laravel Envoy Script Generator Works

This tool turns a small set of deployment inputs into a structured Envoy script that follows a predictable flow: define servers, set shared variables, then run tasks (or a story) in a safe order. Envoy uses a Blade-like syntax, so the output file remains easy to review in code review, version control, and audits.

The generated script focuses on a practical, widely-used pattern: timestamped releases stored in a releases directory and a current symlink that points to the active release. This structure supports fast rollbacks and reduces the chance of deploying into a “half-updated” folder when multiple steps need to run.

Step-by-Step

  • 1) Add servers: Provide one server per line (for example [email protected]). The generator converts this into an @servers array that Envoy can target by name.
  • 2) Define deployment variables: Enter the repository URL, branch, and deployment path. The output includes an @setup block that centralizes these values and derives useful paths like $releases_dir and $app_dir.
  • 3) Choose common steps: Enable or disable typical deployment actions such as maintenance mode, migrations, asset builds, and queue restarts. You can keep things minimal for an API-only app or include more steps for a full-stack application.
  • 4) Generate tasks and a story: The script includes discrete tasks for cloning, installing dependencies, optimizing, switching the current symlink, and cleaning old releases. A single @story orchestrates the order so deployments remain consistent.
  • 5) Copy, commit, run: Save the output as Envoy.blade.php at your repository root (or wherever your team keeps deployment files), commit it, then execute with envoy run deploy (or your chosen story name).
  • 6) Iterate safely: Treat the Envoy file as living infrastructure code. As your stack evolves, you can add tasks for health checks, warming caches, rotating queues, or notifying chat tools, while keeping the core flow stable.

Key Features

Server list parsing that stays human-friendly

Instead of forcing JSON or YAML, you can maintain a simple one-line-per-server list. This keeps the input fast to edit and easy to share with teammates. The generated @servers block remains readable and close to what the Envoy documentation expects.

This style is also convenient for quick updates. When a server IP changes, or you add a new environment, you can update a single line and regenerate. Many teams use names like production, staging, and worker to represent distinct roles, and Envoy’s targeting makes it clear where commands will run.

Opinionated deployment structure with sensible defaults

The generator produces a layout that most Laravel teams recognize: release directories, a current symlink, a timestamped release identifier, and a cleanup step that keeps only a configurable number of releases. This pattern reduces risk because you can roll back by pointing the symlink at a previous release.

The defaults are intentionally practical: a conservative number of retained releases, dependency installation flags that work well in CI and production, and caching/optimization commands that improve runtime performance. You can still adjust every value after generation, but the initial result is designed to run successfully with minimal edits.

Toggleable “real-world” steps

Different projects need different steps. Some apps require php artisan migrate --force on every release, while others avoid migrations on deploy. Some apps build assets on the server, while others ship compiled assets. The tool lets you include or exclude these steps so the output matches your workflow.

These toggles are especially helpful when you are standardizing deployments across multiple repositories. Your API service might skip asset builds entirely, while your admin panel app might include an on-server build step. With consistent structure and optional steps, your team can reuse the same approach without forcing one-size-fits-all commands.

Copy-ready output with download option

Once generated, the Envoy file is presented as plain text so you can copy it into your editor or download it as a TXT file. This makes it easy to adapt the script for multiple environments (production, staging, QA) with minimal changes.

Because the output is plain text, it also works well with code review. Teammates can quickly see which commands will run, which paths are used, and whether safety checks are present. This is one of Envoy’s strengths: it is easy to read and reason about compared to complex YAML-driven pipelines.

Extendable foundation for custom tasks

Teams often add extra tasks: clearing caches for a specific package, running a health check endpoint, warming up a cache, restarting a process manager, or sending a deployment notification. The generator includes an optional section where you can paste additional Envoy tasks or hooks and keep everything in one file.

This approach helps you keep your deployment logic close to your application code. Over time, you can add tasks such as database backups, smoke tests, or dependency audits. When you can generate a strong baseline and then extend it thoughtfully, your deployment process becomes both reliable and tailored.

Use Cases

  • Standard Laravel app deployments: Automate clone, install, migrate, optimize, and switch symlink in a repeatable order for monoliths, APIs, and admin panels.
  • Multi-environment releases: Maintain separate server groups for production and staging while keeping the same task definitions and variable names across environments.
  • Team onboarding: Provide a single Envoy.blade.php file that documents the deployment workflow and reduces “tribal knowledge” and repeated questions.
  • Audit-friendly changes: Keep deployment logic in version control so you can review updates to commands, paths, and safety checks alongside application changes.
  • Safer maintenance windows: Put the app into maintenance mode during critical steps and bring it back up only after a successful switch, especially for deployments with risky migrations.
  • Queue-based applications: Restart workers after deployment so background jobs pick up new code and configuration, reducing confusing “old worker” behavior.
  • Release retention and rollbacks: Keep multiple historical releases for quick rollback while automatically cleaning up older releases so disk usage stays predictable.

Whether you deploy a small internal tool or a high-traffic API, a consistent Envoy script reduces human error. It also makes deployments more accessible: instead of “remembering commands,” you run a named story with an intentional ordering of steps.

Many teams combine Envoy with CI. CI builds and tests code, then triggers Envoy to run the final, server-side steps. The generated script can serve as the last-mile deployment layer: putting the release in place, installing dependencies, switching symlinks, and running framework optimizations at the moment they matter.

Optimization Tips

Keep secrets out of the Envoy file

Envoy scripts are typically committed to your repository. Avoid hardcoding credentials or tokens. Use SSH keys for server access, rely on deploy keys for private Git repositories, and use environment variables or secrets managers for application secrets. Treat the Envoy file as infrastructure code that should be safe to share with the team.

If you need environment-specific values, consider reading them from server-side environment files or injecting them via your CI system. The goal is to keep the Envoy file stable and non-sensitive while still supporting multiple environments.

Prefer idempotent and testable commands

Deploy scripts should be safe to run multiple times. Commands like composer install, cache rebuilds, and queue:restart are naturally repeatable. When you add custom steps, consider what happens if a deploy is retried, or if a previous deploy partially completed. Defensive checks (for example, “create directory if missing”) keep deployments resilient.

When possible, build tasks that can be run independently. A “health check” task, for example, can be used after deployment and during incident response. Small, focused tasks also make it easier to troubleshoot when something fails.

Plan for database migration safety

Migrations are often the most deployment-sensitive step. If your schema changes can lock tables or take time, use backward-compatible, “expand/contract” approaches: add new columns and code paths first, then remove old ones later. For very large datasets, consider online schema change tools and scheduled maintenance windows.

The generator can include migrations in the deploy story, but your database strategy should guide whether this is a good default for production. In some teams, migrations are run as a separate story so the database step can be monitored more closely.

Validate the workflow on staging first

Before enabling migrations, queue restarts, or maintenance mode in production, run the same script against a staging environment. This confirms that paths, permissions, and binaries are correct. Once your staging deploy is reliable, production deployments become a predictable, low-stress operation.

Staging is also the right place to validate that your build step matches the server’s runtime. For example, if you build assets on the server, confirm Node and npm versions, and ensure that the build output is in the expected directories.

FAQ

Laravel Envoy is a SSH-based task runner that lets you define deployment and maintenance commands in a Blade-style PHP file. Use it when you want repeatable deployments and server tasks without maintaining a full configuration management system for simple workflows. It is especially useful for small teams that want readable automation they can commit to Git.

The output uses a “releases + current symlink” approach, which is the foundation of zero-downtime patterns. True zero downtime also depends on your runtime (queue workers, PHP-FPM reloads, cache warming, and database migration strategy), so you should review and adjust tasks to match your infrastructure. The generator gives you a safe baseline you can build on.

Add new lines to the server list in the generator (or edit the @servers array in your Envoy file) and reference the new server key in your tasks or stories. Many teams keep separate keys like production, staging, and qa for clarity. You can also create environment-specific stories to keep production and staging flows slightly different.

Yes. Envoy supports defining a local server like 127.0.0.1. This is useful for running project maintenance tasks such as clearing caches or generating documentation. For deployments, most users run tasks against remote servers using SSH accounts and keys, but local tasks can still complement your workflow.

It can be safe when you follow “expand/contract” migration practices and avoid destructive changes during peak traffic. If your migrations can lock large tables or take a long time, consider running them separately, using online schema change tools, or scheduling migrations for a controlled window. For critical systems, monitor migrations carefully and keep a rollback plan ready.

Why Choose This Tool?

Laravel Envoy is intentionally lightweight, which is great for teams that want simple, readable deployment scripts. The downside is that you often end up recreating the same scaffolding from scratch: release folders, symlinks, cleanup commands, and the “usual” Laravel optimization steps. This generator gives you a strong baseline that matches common Laravel deployment conventions, so you can focus on the project-specific details that actually matter.

Use the output as a starting point, commit it, and iterate. Over time, your Envoy file becomes a living playbook: a single source of truth for how the application is deployed, maintained, and recovered. When your deployment process is documented as code, releases become faster, safer, and easier to hand off across the team. If you ever need to troubleshoot an incident, having clear, versioned tasks is a practical advantage.