Best Cosmetic Hospitals Near You

Compare top cosmetic hospitals, aesthetic clinics & beauty treatments by city.

Trusted • Verified • Best-in-Class Care

Explore Best Hospitals

Zero Downtime Deployment for Laravel Using PHP Deployer

here’s a beginner-friendly version of the guide you shared on Zero Downtime Deployment using PHP Deployer for Laravel projects. It’s written to help learners easily understand and follow the process without feeling overwhelmed:


🚀 Zero Downtime Deployment for Laravel Using PHP Deployer – A Beginner’s Guide

✅ What is Zero Downtime Deployment?

Imagine updating your website without any interruptions — users stay online, no glitches, no downtime. That’s zero downtime deployment.

It means:

  • Your users won’t notice when you’re deploying updates.
  • Your website or app stays online all the time, even while new code is being uploaded.

This is usually done through smart strategies like:

  • Blue-Green Deployments
  • Canary Releases
  • Rolling Updates

These techniques help push updates slowly, keeping the old version alive until the new one is ready and stable.


💡 Why It’s Easier with PHP

PHP is an interpreted language, which means:

  • No need to compile.
  • You can switch between code versions using tricks like symlinks (symbolic links) without restarting the whole server.

But, for a proper professional deployment, you still need to:

  • Run database migrations
  • Clear caches
  • Build frontend assets
  • Restart services (if needed)

To help with all that, let’s meet the hero of this guide: PHP Deployer!


🧰 What is PHP Deployer?

PHP Deployer (also called just “Deployer”) is a tool to automate the deployment of PHP apps.

With Deployer, you can:

  • Deploy to one or more servers
  • Run tasks like building assets or migrating databases
  • Manage releases easily

It even comes with built-in support (recipes) for popular frameworks — like Laravel!


🛠️ Step-by-Step: Zero Downtime Deployment for Laravel

Let’s get started.


Step 1: Install PHP Deployer

In your Laravel project, open a terminal and run:

composer require --dev deployer/deployer

This installs Deployer as a development tool in your project.


Step 2: Initialize Deployer

Now run:

vendor/bin/dep init

This sets up Deployer in your Laravel app.


Step 3: Answer Setup Questions

During setup, Deployer will ask:

  1. File format – Just press Enter to choose the default (PHP).
  2. Choose a recipe – Select Laravel.
  3. Enter Git repo URL – Paste your GitHub or GitLab project URL.
  4. Project name – Name your project anything you like.
  5. Host IP/Domain – Enter your server IP or hostname.
  6. Confirm setup – Hit Enter.

After this, a file named deploy.php will be created in your project.


Step 4: Update deploy.php

Your deploy.php will look like this:

<?php
namespace Deployer;

require 'recipe/laravel.php';

set('repository', 'https://github.com/your-repo.git');

host('your.server.ip')
    ->set('remote_user', 'your-ssh-user')
    ->set('deploy_path', '~/your-project-path');

after('deploy:failed', 'deploy:unlock');
  • Replace the repository URL, user, and path with your actual info.
  • This tells Deployer how to connect to your server and where to deploy the code.

Step 5: If You’re Using Vite (for Laravel Mix)

Laravel uses Vite for frontend asset building. So, add this to your deploy.php:

desc('Install & build npm packages');

task('npm:build', function () {
    run('cd {{release_path}} && npm ci && npm run build');
});

after('artisan:migrate', 'npm:build');

This ensures your JS/CSS files get built after the migration step.


Step 6: Add Server’s SSH Key to Git

Your server needs permission to pull your code from Git.

To do that:

  1. SSH into your server
  2. Run this to view the public key:
cat ~/.ssh/id_rsa.pub
  1. Copy the output.
  2. Go to your Git repo → Settings → SSH and GPG Keys
  3. Click “New SSH Key”, paste the copied key, and save.

Now your server can pull your code securely.


Step 7: Deploy Your Laravel App

Back in your project folder on your local machine, run:

vendor/bin/dep deploy

During the first deployment, you might see:

Warning: Your .env file is empty! Skipping...

No worries! We’ll fix that next.


Step 8: Set Up the .env File on the Server

You only need to do this once:

  1. SSH into your server:
vendor/bin/dep ssh
  1. Copy the example .env file to the shared folder:
cp .env.example ../../shared/.env
  1. Open it and edit values as needed:
nano ../../shared/.env

Make sure APP_ENV=production

  1. If needed, generate a new key:
php artisan key:generate
  1. Exit the SSH session:
exit

Step 9: Deploy Again

Now that your .env is set, run the deploy again:

vendor/bin/dep deploy

🎉 That’s it! Your Laravel project is now deployed with zero downtime.


🔁 How It Works Behind the Scenes

  • Every time you deploy, Deployer creates a new folder (release) for that version.
  • Then, it symlinks that folder to the current directory.
  • Your web server always points to current, so switching versions is smooth and instant.

✅ Benefits of This Approach

  • No downtime.
  • Easy rollbacks.
  • Smooth experience for users.
  • Cleaner deployment workflow for developers.

🎉 Final Thoughts

Zero downtime deployment sounds fancy, but with tools like PHP Deployer, it’s easy and powerful.

Just install it, set up your deploy config, connect your server, and you’re good to go. This is one of the best ways to scale your Laravel apps professionally and deliver updates without annoying your users.


Best Cardiac Hospitals Near You

Discover top heart hospitals, cardiology centers & cardiac care services by city.

Advanced Heart Care • Trusted Hospitals • Expert Teams

View Best Hospitals
<p data-start="140" data-end="435">I’m Abhishek, a DevOps, SRE, DevSecOps, and Cloud expert with a passion for sharing knowledge and real-world experiences. I’ve had the opportunity to work with <a class="decorated-link" href="https://www.cotocus.com/" target="_new" rel="noopener" data-start="300" data-end="335">Cotocus</a> and continue to contribute to multiple platforms where I share insights across different domains:</p> <ul data-start="437" data-end="922"> <li data-start="437" data-end="514"> <p data-start="439" data-end="514"><a class="decorated-link" href="https://www.devopsschool.com/" target="_new" rel="noopener" data-start="439" data-end="485">DevOps School</a> – Tech blogs and tutorials</p> </li> <li data-start="515" data-end="599"> <p data-start="517" data-end="599"><a class="decorated-link" href="https://www.holidaylandmark.com/" target="_new" rel="noopener" data-start="517" data-end="569">Holiday Landmark</a> – Travel stories and guides</p> </li> <li data-start="600" data-end="684"> <p data-start="602" data-end="684"><a class="decorated-link" href="https://www.stocksmantra.in/" target="_new" rel="noopener" data-start="602" data-end="647">Stocks Mantra</a> – Stock market strategies and tips</p> </li> <li data-start="685" data-end="764"> <p data-start="687" data-end="764"><a class="decorated-link" href="https://www.mymedicplus.com/" target="_new" rel="noopener" data-start="687" data-end="732">My Medic Plus</a> – Health and fitness guidance</p> </li> <li data-start="765" data-end="841"> <p data-start="767" data-end="841"><a class="decorated-link" href="https://www.truereviewnow.com/" target="_new" rel="noopener" data-start="767" data-end="814">TrueReviewNow</a> – Honest product reviews</p> </li> <li data-start="842" data-end="922"> <p data-start="844" data-end="922"><a class="decorated-link" href="https://www.wizbrand.com/" target="_new" rel="noopener" data-start="844" data-end="881">Wizbrand</a> – SEO and digital tools for businesses</p> </li> </ul> <p data-start="924" data-end="1021">I’m also exploring the fascinating world of <a class="decorated-link" href="https://www.quantumuting.com/" target="_new" rel="noopener" data-start="968" data-end="1018">Quantum Computing</a>.</p>

Related Posts

Improving Restaurant Operations Through Better Booking and Seating Planning

On a bustling Friday evening, the front desk of a restaurant can feel like mission control during launch. Phones ring incessantly for last-minute tables, walk-in parties crowd…

Read More

CI/CD Pipeline Architecture at Scale: From Bottlenecks to Autoscaling Runners

A continuous integration and continuous delivery (CI/CD) pipeline that serves a ten-person engineering team working out of two repositories rarely survives contact with rapid organizational growth. When…

Read More

Top 10 Enterprise Data Fabric Platforms: Features, Pros, Cons & Comparison

Introduction In the modern era of hybrid and multi-cloud environments, data has become increasingly fragmented. Enterprise data fabric platforms have emerged as a critical architectural layer that…

Read More

Top 10 KYC/AML Compliance Tools: Features, Pros, Cons and Comparison

IntroductionKYC and AML compliance tools help organizations verify customer identity, detect fraud risk, and screen people or businesses against sanctions, watchlists, and adverse media. They reduce manual…

Read More

DevOps Consulting Netherlands: Platform Engineering & SRE Guide

Spend an afternoon talking with engineering directors across Amsterdam, Rotterdam, or the Eindhoven technology belt, and you will hear a recurring story. Their teams write elegant, performant…

Read More

CI/CD Implementation Strategy: Proven DevOps Consulting Best Practices for Modern Teams

Modern software delivery often breaks down not from a lack of tooling, but from a lack of cohesion. Engineering teams frequently adopt Continuous Integration and Continuous Delivery…

Read More
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x