Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

VETO87's avatar

maintain Laravel projects after deployment

Hello, I'm new to laravel and managed somehow to deploy to project but the problem is when I have to update them. I do it from the production on the server. I know it's wrong but because of deployment issues that everytime I have to solve such as that creating the .htaccess and env file every time to update.

I use github to get clone of my files then I do composer .... . .. . so if i want to update i'm gonna delete all files then get new clone of my github project is there some technique to make it easy?

0 likes
3 replies
OussamaMater's avatar
Level 37

No, You can use Github Actions, so that whenever you push some updates to your application it automatically pushes these updates to the production server, this is what we call CD/CI. I am sure these articles will help you:

  1. https://dev.to/kenean50/automate-your-laravel-app-deployment-with-github-actions-2g7j
  2. https://www.mitrais.com/news-updates/how-to-create-ci-cd-with-github-action-and-laravel/

If you don't want to use Github as an intermediate, you can use "Git Hooks" which you set on the production server and whenever you make a change to the code push to the production server (you can have multiple remote repositories, so github and the production server). This article will help you (note that it is an old article, he is using Laravel 5.6, but still the same concepts)

  1. https://devmarketer.io/learn/deploy-laravel-5-app-lemp-stack-ubuntu-nginx/
1 like
sr57's avatar

then I do composer ...

Which composer command?

You should/must never use composer update on your Prod server.

You have 2 major ways of deployment

  • dev to prod sever and use composer install

  • staging server to prod server

In all the case you must use use composer update on you dev/staging server(s) and to do the tests before updating the prod server.

Snapey's avatar

I use the following process on my servers

  1. create a folder based on the current timestamp
  2. git pull from the repository
  3. composer install
  4. copy .env from a master folder
  5. symlink from master storage folder to the deployment storage
  6. symlink from public_html to public in the deployment folder

this seems a lot but it's all in a bash script that takes less than 15 seconds to run, and immediately swaps from one deployment to the next with no downtime

Please or to participate in this conversation.