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

manel69's avatar

Doubt with Laravel deploy, Git and .gitignore files

Hi everyone, We have a start-up, and are going to Laravel few weeks ago.

Now we have a Bitbucket repo with all Laravel project files inside, that's working great. We have two debian servers, one for testing and other for production. The repo is cloned only in the testing server (on /var/www/project) and locally on my pc and into other developer pc.

I've done bash script in the testing server that does the following: "git pull origin master" and "chown -R www-data:www-data bootstrap/cache storage", as like says the official docs of Laravel 5.4.

My principal "doubt" are the files mentioned inside .gitiginore file (I don't touched it, is the original), that aren't present in the repo, what is correct. But without these files, the project doesn't work anymore.

Finally, my ask is: What (or which best practice) I should do to "publish" my project on the production server? What I have to do if another developer want to pull it and test on his computer?

The workaround I've tested is creating a new laravel project on a folder named "test", make a git clone repo to "temp" folder, and finally copy (with rsync) all content of the "temp" folder to a "test" folder, and remove the "temp" folder.

I don't know if I explained correctly, but I think that my problem (or my ignorance) is understood.

Thanks for the attention.

PD: Sorry for my poor English.

0 likes
2 replies
neilherbertuk's avatar
Level 9

Hi MANEL69,

Your . gitignore file contains what it does for good reason. Firstly it keeps your project small so it's quick to deploy. Your git repo is set using this to not include your vendor folder, as everything in your vendor folder is already on a git repo, it does not make sense to duplicate code, it also allows you to make sure the packages you've pulled in are up to date (security fixes etc).

Secondly, for security it does not include your .env file, this is to prevent passwords getting stored in version control. As you have access to the server you are deploying on you can copy your .env file, or create a production version manually, once it's in place it won't get overwritten as git will not touch it.

Your vendor folder is easy to sort, you will need to ensure that composer is installed on the server you are deploying to, simply run the following from the root of your project.

composer install

This will install all of the missing dependencies within your vendor folder.

A typical workflow pulling down a project would be to do a git clone of the project, set the permissions and then run composer install, followed by manually setting up your .env file.

Neil

1 like
manel69's avatar

Thanks @neilherbertuk, that's exactly I wanted. Now I could update my script to deploy just adding "composer install" and copying a previously filled out ".env" and we are ready to go.

:)

Please or to participate in this conversation.