Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here
Premium Members Only
Join to unlock this tutorial and all of our courses.
Tutorial Premium Tutorial

Laravel Deployment Script: 4 Steps to Add Changes on Server

November 24, 2022
6 min read

Deploying changes of your Laravel project to the server is not a simple process. I would separate that into 4 separate phases: code changes, dependencies, DB changes, and environment cleanup. Let's take a look at all of them, one by one.

So, you've pushed/merged the latest changes to the GitHub branch, you (or your auto deployment script robot) SSH into the server, and... do what?


Phase 0. Putting the system down.

If we take into account those phases, the full deployment may take up to 5-10 seconds, or even more. What if during that time, someone is using your application and may...

Premium Members Only

This advanced tutorial is available exclusively to Laravel Daily Premium members.

Premium membership includes:

Access to all premium tutorials
Video and Text Courses
Private Discord Channel

Comments & Discussion

L
lloricode ✓ Link copied!

I just made a bash file for this, like pull-main.sh, then just run bash pull-main.sh in remote project directory, and using ploi for creating and managing server.

MB
Matthew Bailey ✓ Link copied!

I noticed you have the clear commands however shouldn't you also have the config, route and view cache commands before running php artisan up like the docs recommend?

https://laravel.com/docs/9.x/deployment#optimizing-configuration-loading

PK
Povilas Korop ✓ Link copied!

From my understanding, clear commands do the cache again automatically. But I may be mistaken here, can you try and confirm?

NS
Nouman Sarwar ✓ Link copied!

Instead of running three commands i.e. php artisan cache:clear php artisan route:clear php artisan view:clear

we should use php artisan optimize:clear It clears all app caching, route, view, config and etc,.

And clear command only clears the cache, while route:cache, config:cache, and view:cache cleared the existing cache and cache it again, It can be done with php artisan optimize:cache as well

Thnx, Regards, -NS

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.