Laravel and Github

Asked

Viewed 540 times

0

Good afternoon, I am currently taking a course and I am in the matter of routes in the course of Laravel, I am following the lessons perfectly. I did the installation of all the requirements that are in class, such as xampp, npm, Composer etc. I did my first local project normally, I did equally in the videos lessons, and everything worked perfectly.

However, I work with Github during my classes, because in the future I will easily consult my codes and by the organization. The point is this, when I send the project to Git, and do the git clone again at another terminal, I checked that the file . env is not coming again, this is due to the fact of the file .gitignore ignore the same.

The question is, is this the right way to get a project into git? Ignoring . env and in case I need to work on the project again, create a file . env based on .env.example and filling the keys?

Detail, how do I create a file . env based on .env.examples? Could someone help me?

1 answer

1

The question is, is this the right way to get a project into git? Ignoring . env and in case I need to work on the project again, create a file . env based on .env.example and filling the keys?

Yes, it is correct. The file .env in Laravel aims to set settings local, for your development environment.

It is very common for you not to add files to the repository that have to do with local machine settings or project external dependency files.

When the file .env is not present, the Laravel will use the settings present in config.

To better understand, Laravel checks the file .env exists. If there is, in the function call env('VALOR', 'valor em produção'), Laravel will take the key value VALOR gift from your .env. If it does not exist, it will use the parameter "valor em produção".

The .gitignore should be used in the .env yes.

For you to have an idea, I already had to work here at the company with two more programmers with me. Each had a database with different definitions, different passwords. When we made the mistake of leaving the .env in the GIT repository, every time an update was sent, the .env were overwritten and the programmer who received the updates had the rework to update the file with the right settings.

So it is correct that the .env be ignored.

Detail, how do I create a file . env based on .env.examples? Could someone help me?

I don’t know if I understand the question very well. Just copy the file .env.example and save him as .env on your machine.

The job of setting it up will be once only, if you ignore it in GIT through the .gitignore

Addendum

To get an idea of what I said about certain files that should be ignored, I usually ignore files like projeto.sublime-project, since it is a configuration file of Sublime Text, and the other programmer who will help me in the development can use Visual Studio Code, for example.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.