Laravel and Github

0

Good afternoon, I am currently taking a course and I am on the subject of routes in the course of laravel, I am following the lessons perfectly. I made the installations of all the requirements that are in class, like xampp, npm, composer etc. I did my first local project normally, I also did video lessons, and everything worked perfectly.

However, I work with Github during my classes, because I can easily consult my codes in the future and by the organization. The question is, when I submit the project to Git, and I make git clone again on another terminal, I checked that the .env file is not coming again, this is because the .gitignore file ignores the same.

The question is, is this the correct way to version a project in laravel using git? Ignoring .env and if I need to work on the project again, create an .env file based on .env.example and filling in the keys?

Detail, how do I make this process of creating an .env file based on .env.examples? Could someone help me?

    
asked by anonymous 29.10.2018 / 15:56

1 answer

1
  

The question is, is this the correct way to version a project in laravel using git? Ignoring .env and if I need to work on the project again, create an .env file based on .env.example and filling in the keys?

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

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

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

To understand better, Laravel checks to see if the .env file exists. If it exists, at the env('VALOR', 'valor em produção') function call, Laravel will get the value of the VALOR key of its .env . If it does not exist, it will use the "valor em produção" parameter.

.gitignore should be used in .env yes.

To give you an idea, I've already had to work here in the company with two more programmers with me. Each had a database with different settings, different passwords. When we made the error of leaving .env in the GIT repository, every time an update was sent, the .env data was overwritten and the programmer who received the updates had the rework to update the file with the correct settings. / p>

Then, it is correct that .env is ignored.

  

Detail, how do I make this process of creating an .env file based on .env.examples? Could someone help me?

I do not know if I understood the question very well. It is only you to copy the .env.example file and save it as .env on your machine.

The job of configuring it will be only once, if you ignore it in the GIT through .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 Sublime Text configuration file, and the other programmer that will help me in the development you can use Visual Studio Code, for example.

    
29.10.2018 / 16:03